ref: adf405496ea36f917709e5d58ba79bebcd3a0fa7
parent: d9bc233f1f38df022864e0700a0514edf89b12d0
author: Bjørn Erik Pedersen <[email protected]>
date: Sun Jul 10 11:10:22 EDT 2016
Fix humanize when string is empty Fixes #2272
--- a/tpl/template_funcs.go
+++ b/tpl/template_funcs.go
@@ -1703,6 +1703,11 @@
if err != nil {
return "", err
}
+
+ if word == "" {
+ return "", nil
+ }
+
return inflect.Humanize(word), nil
}
--- a/tpl/template_funcs_test.go
+++ b/tpl/template_funcs_test.go
@@ -1805,8 +1805,11 @@
expected string
}{
{humanize, "MyCamel", "My camel"},
+ {humanize, "", ""},
{pluralize, "cat", "cats"},
+ {pluralize, "", ""},
{singularize, "cats", "cat"},
+ {singularize, "", ""},
} {
result, err := this.inflectFunc(this.in)