Skip to content

Commit

Permalink
Add hasPrefix function to rendering template
Browse files Browse the repository at this point in the history
  • Loading branch information
Marie Roque committed Sep 22, 2023
1 parent 244d1af commit 0654f7a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ func RenderTemplate(templateData interface{}, templateLocation string) ([]byte,
return buf.String(), nil
}

funcMap["hasPrefix"] = strings.HasPrefix
funcMap["hasPrefix"] = func(prefix string, str string) bool {
return strings.HasPrefix(prefix, str)
}

tpl, err := tpl.Funcs(sprig.FuncMap()).Funcs(funcMap).ParseGlob(templateLocation)
if err != nil {
Expand Down

0 comments on commit 0654f7a

Please sign in to comment.