Skip to content

Commit

Permalink
Add toUpper and toLower template funcs.
Browse files Browse the repository at this point in the history
Closes #236
  • Loading branch information
jrasell committed Sep 27, 2018
1 parent 6ae4961 commit 1de7af8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion template/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"text/template"
"time"

Expand All @@ -20,6 +21,7 @@ func funcMap(consulClient *consul.Client) template.FuncMap {
"consulKey": consulKeyFunc(consulClient),
"consulKeyExists": consulKeyExistsFunc(consulClient),
"consulKeyOrDefault": consulKeyOrDefaultFunc(consulClient),
"env": envFunc(),
"loop": loop,
"parseBool": parseBool,
"parseFloat": parseFloat,
Expand All @@ -29,7 +31,8 @@ func funcMap(consulClient *consul.Client) template.FuncMap {
"timeNow": timeNowFunc,
"timeNowUTC": timeNowUTCFunc,
"timeNowTimezone": timeNowTimezoneFunc(),
"env": envFunc(),
"toLower": toLower,
"toUpper": toUpper,
}
}

Expand Down Expand Up @@ -213,6 +216,14 @@ func timeNowTimezoneFunc() func(string) (string, error) {
}
}

func toLower(s string) (string, error) {
return strings.ToLower(s), nil
}

func toUpper(s string) (string, error) {
return strings.ToUpper(s), nil
}

func envFunc() func(string) (string, error) {
return func(s string) (string, error) {
if s == "" {
Expand Down

0 comments on commit 1de7af8

Please sign in to comment.