From 8218e45cbcc756333bee6b6245ef5a4c2aaa273f Mon Sep 17 00:00:00 2001 From: James Nugent Date: Wed, 17 May 2017 20:48:12 -0400 Subject: Add "replaceAll" function and documentation This commit adds a `replaceAll` function which takes three arguments - an original string, the substring to replace, and the string with which to replace it. This is of particular use when generating node names from IP addresses where the node name may not contain "." characters. --- gomplate.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gomplate.go') diff --git a/gomplate.go b/gomplate.go index 28e623ab..c2490e81 100644 --- a/gomplate.go +++ b/gomplate.go @@ -4,7 +4,6 @@ import ( "io" "log" "net/url" - "strings" "text/template" @@ -39,6 +38,7 @@ func (g *Gomplate) RunTemplate(text string, out io.Writer) { func NewGomplate(data *Data, leftDelim, rightDelim string) *Gomplate { env := &Env{} typeconv := &TypeConv{} + stringfunc := &stringFunc{} ec2meta := aws.NewEc2Meta() ec2info := aws.NewEc2Info() return &Gomplate{ @@ -65,6 +65,7 @@ func NewGomplate(data *Data, leftDelim, rightDelim string) *Gomplate { "contains": strings.Contains, "hasPrefix": strings.HasPrefix, "hasSuffix": strings.HasSuffix, + "replaceAll": stringfunc.replaceAll, "split": strings.Split, "splitN": strings.SplitN, "title": strings.Title, -- cgit v1.2.3