From 915c3e5aa54f71450323861fd9e87edf215d9db0 Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Mon, 11 Sep 2023 10:27:28 +0200 Subject: [PATCH] Make `strings.Title` not lowercase acronyms Sets the `NoLower` option so that acronyms are not lowercased. --- funcs/strings.go | 2 +- funcs/strings_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/funcs/strings.go b/funcs/strings.go index 161d0f49f..f95e6bf5a 100644 --- a/funcs/strings.go +++ b/funcs/strings.go @@ -235,7 +235,7 @@ func (StringFuncs) TrimSuffix(cutset string, s interface{}) string { // Title - func (f *StringFuncs) Title(s interface{}) string { - return cases.Title(f.tag).String(conv.ToString(s)) + return cases.Title(f.tag, cases.NoLower).String(conv.ToString(s)) } // ToUpper - diff --git a/funcs/strings_test.go b/funcs/strings_test.go index 115219767..fdc64a470 100644 --- a/funcs/strings_test.go +++ b/funcs/strings_test.go @@ -80,6 +80,8 @@ func TestTitle(t *testing.T) { {`ljoo džar`, `Ljoo Džar`}, {`foo bar᳇baz`, `Foo Bar᳇Baz`}, // ᳇ should be treated as punctuation {`foo,bar&baz`, `Foo,Bar&Baz`}, + {`FOO`, `FOO`}, + {`bar FOO`, `Bar FOO`}, } for _, d := range testdata {