aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/strings/strings.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-09-07 09:05:25 +0200
committerBjørn Erik Pedersen <[email protected]>2018-09-07 09:08:14 +0200
commite5d66074ce1ed4e0fe329e3fdef66f8b6fd5dc55 (patch)
treeff880dcb8d763708611ff6a306f4b5d13afa8aa0 /tpl/strings/strings.go
parentd970327d7b994b495ef3bb468c3e0599b0deef5a (diff)
downloadhugo-e5d66074ce1ed4e0fe329e3fdef66f8b6fd5dc55.tar.gz
hugo-e5d66074ce1ed4e0fe329e3fdef66f8b6fd5dc55.zip
tpl/strings: Add strings.FirstUpper
Fixes #5174
Diffstat (limited to 'tpl/strings/strings.go')
-rw-r--r--tpl/strings/strings.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/tpl/strings/strings.go b/tpl/strings/strings.go
index 1864bb9e0..9b8409ed6 100644
--- a/tpl/strings/strings.go
+++ b/tpl/strings/strings.go
@@ -325,6 +325,16 @@ func (ns *Namespace) Title(s interface{}) (string, error) {
return ns.titleFunc(ss), nil
}
+// FirstUpper returns a string with the first character as upper case.
+func (ns *Namespace) FirstUpper(s interface{}) (string, error) {
+ ss, err := cast.ToStringE(s)
+ if err != nil {
+ return "", err
+ }
+
+ return helpers.FirstUpper(ss), nil
+}
+
// ToLower returns a copy of the input s with all Unicode letters mapped to their
// lower case.
func (ns *Namespace) ToLower(s interface{}) (string, error) {