templateUtil.go 479 Bytes
Newer Older
Eric Myhre's avatar
Eric Myhre committed
1 2 3 4 5 6 7 8 9
package gengo

import (
	"io"
	"text/template"

	wish "github.com/warpfork/go-wish"
)

10
func doTemplate(tmplstr string, w io.Writer, adjCfg *AdjunctCfg, data interface{}) {
11
	tmpl := template.Must(template.New("").
12 13 14 15 16
		Funcs(template.FuncMap{
			"TypeSymbol":       adjCfg.TypeSymbol,
			"FieldSymbolLower": adjCfg.FieldSymbolLower,
			"FieldSymbolUpper": adjCfg.FieldSymbolUpper,
		}).
17
		Parse(wish.Dedent(tmplstr)))
Eric Myhre's avatar
Eric Myhre committed
18 19 20 21
	if err := tmpl.Execute(w, data); err != nil {
		panic(err)
	}
}