From 4195ee786cce637615862d7900addc23b006db5a Mon Sep 17 00:00:00 2001 From: Sven Walter Date: Thu, 10 Aug 2017 15:03:27 +0200 Subject: [PATCH] add makeSlice template function --- pkg/templates/functions.go | 5 +++++ pkg/templates/render.go | 1 + 2 files changed, 6 insertions(+) diff --git a/pkg/templates/functions.go b/pkg/templates/functions.go index 135717b..daea3fd 100644 --- a/pkg/templates/functions.go +++ b/pkg/templates/functions.go @@ -15,3 +15,8 @@ func IdentifierFunc(s string) string { s = strings.Trim(s, "-") return s } + +// Example: https://stackoverflow.com/a/25013152/393157 +func MakeSliceFunc(elements ...interface{}) []interface{} { + return elements +} diff --git a/pkg/templates/render.go b/pkg/templates/render.go index c8bf6f6..cb2e897 100644 --- a/pkg/templates/render.go +++ b/pkg/templates/render.go @@ -25,6 +25,7 @@ func Render(templateString string, variables Variables) (string, error) { "ToUpper": strings.ToUpper, "ToLower": strings.ToLower, "Identifier": IdentifierFunc, + "MakeSlice": MakeSliceFunc, } t, err := template.