diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go index ea1ce8a51..b34300ab2 100644 --- a/tpl/template_funcs.go +++ b/tpl/template_funcs.go @@ -1703,6 +1703,11 @@ func humanize(in interface{}) (string, error) { if err != nil { return "", err } + + if word == "" { + return "", nil + } + return inflect.Humanize(word), nil } diff --git a/tpl/template_funcs_test.go b/tpl/template_funcs_test.go index 32e6e50f5..f0d123c0f 100644 --- a/tpl/template_funcs_test.go +++ b/tpl/template_funcs_test.go @@ -1805,8 +1805,11 @@ func TestInflect(t *testing.T) { expected string }{ {humanize, "MyCamel", "My camel"}, + {humanize, "", ""}, {pluralize, "cat", "cats"}, + {pluralize, "", ""}, {singularize, "cats", "cat"}, + {singularize, "", ""}, } { result, err := this.inflectFunc(this.in)