diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-10-15 23:03:21 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-10-22 21:28:01 -0400 |
| commit | d8257b605db77d1bb5246f08253f39dabe8cabd0 (patch) | |
| tree | f9910802680471b5e87e96871fc2664e2e618ea8 /gomplate.go | |
| parent | 8b71e0c890a422e14b1ba12f02f01427a7710d66 (diff) | |
Plugins for custom functions
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'gomplate.go')
| -rw-r--r-- | gomplate.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gomplate.go b/gomplate.go index beb728d1..ec3a62ad 100644 --- a/gomplate.go +++ b/gomplate.go @@ -49,11 +49,11 @@ func (g *gomplate) runTemplate(t *tplate) error { type templateAliases map[string]string // newGomplate - -func newGomplate(d *data.Data, leftDelim, rightDelim string, nested templateAliases, context interface{}) *gomplate { +func newGomplate(funcMap template.FuncMap, leftDelim, rightDelim string, nested templateAliases, context interface{}) *gomplate { return &gomplate{ leftDelim: leftDelim, rightDelim: rightDelim, - funcMap: Funcs(d), + funcMap: funcMap, nestedTemplates: nested, context: context, } @@ -126,7 +126,12 @@ func RunTemplates(o *Config) error { if err != nil { return err } - g := newGomplate(d, o.LDelim, o.RDelim, nested, c) + funcMap := Funcs(d) + err = bindPlugins(o.Plugins, funcMap) + if err != nil { + return err + } + g := newGomplate(funcMap, o.LDelim, o.RDelim, nested, c) return g.runTemplates(o) } |
