Skip to content

Commit

Permalink
Expose ToInt conversion for usage in template
Browse files Browse the repository at this point in the history
Allow usage of strconv.Atoi method in templates to convert environment variables to int for usage with the "index" method
  • Loading branch information
derBiggi authored Jan 11, 2017
1 parent 0cb8920 commit 4502dfc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/QubitProducts/bamboo/services/service"
"strings"
"text/template"
"strconv"
)

func hasKey(data map[string]service.Service, appId string) bool {
Expand All @@ -29,7 +30,8 @@ func RenderTemplate(templateName string, templateContent string, data interface{
"Join": strings.Join,
"Replace": strings.Replace,
"ToUpper": strings.ToUpper,
"ToLower": strings.ToLower}
"ToLower": strings.ToLower,
"ToInt": strconv.Atoi}

tpl := template.Must(template.New(templateName).Funcs(funcMap).Parse(templateContent))

Expand Down

0 comments on commit 4502dfc

Please sign in to comment.