Skip to content

Commit 91b2b5f

Browse files
authored
Merge pull request #237 from jrasell/gh_236
Add toUpper and toLower template funcs.
2 parents 6ae4961 + 1de7af8 commit 91b2b5f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: template/funcs.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"strconv"
9+
"strings"
910
"text/template"
1011
"time"
1112

@@ -20,6 +21,7 @@ func funcMap(consulClient *consul.Client) template.FuncMap {
2021
"consulKey": consulKeyFunc(consulClient),
2122
"consulKeyExists": consulKeyExistsFunc(consulClient),
2223
"consulKeyOrDefault": consulKeyOrDefaultFunc(consulClient),
24+
"env": envFunc(),
2325
"loop": loop,
2426
"parseBool": parseBool,
2527
"parseFloat": parseFloat,
@@ -29,7 +31,8 @@ func funcMap(consulClient *consul.Client) template.FuncMap {
2931
"timeNow": timeNowFunc,
3032
"timeNowUTC": timeNowUTCFunc,
3133
"timeNowTimezone": timeNowTimezoneFunc(),
32-
"env": envFunc(),
34+
"toLower": toLower,
35+
"toUpper": toUpper,
3336
}
3437
}
3538

@@ -213,6 +216,14 @@ func timeNowTimezoneFunc() func(string) (string, error) {
213216
}
214217
}
215218

219+
func toLower(s string) (string, error) {
220+
return strings.ToLower(s), nil
221+
}
222+
223+
func toUpper(s string) (string, error) {
224+
return strings.ToUpper(s), nil
225+
}
226+
216227
func envFunc() func(string) (string, error) {
217228
return func(s string) (string, error) {
218229
if s == "" {

0 commit comments

Comments
 (0)