cmd: Reuse template in helpers

This commit is contained in:
Albert Nigmatzianov 2017-04-29 15:54:32 +02:00
parent 0dd1c429a3
commit 66cfd1f132

View file

@ -23,10 +23,6 @@ import (
"text/template" "text/template"
) )
var funcMap = template.FuncMap{
"comment": commentifyString,
}
var projectPath string var projectPath string
var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"} var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"}
@ -87,8 +83,11 @@ func exists(path string) bool {
return false return false
} }
var tmpl = template.New("").Funcs(template.FuncMap{"comment": commentifyString})
func executeTemplate(tmplStr string, data interface{}) (string, error) { func executeTemplate(tmplStr string, data interface{}) (string, error) {
tmpl, err := template.New("").Funcs(funcMap).Parse(tmplStr) var err error
tmpl, err = tmpl.Parse(tmplStr)
if err != nil { if err != nil {
return "", err return "", err
} }