Commit 125369d1 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

template/interpolate: can specify template data

parent ff6573ce
......@@ -8,6 +8,10 @@ import (
// Context is the context that an interpolation is done in. This defines
// things such as available variables.
type Context struct {
// Data is the data for the template that is available
Data interface{}
// DisableEnv disables the env function
DisableEnv bool
}
......@@ -25,7 +29,10 @@ func (i *I) Render(ctx *Context) (string, error) {
}
var result bytes.Buffer
data := map[string]interface{}{}
var data interface{}
if ctx != nil {
data = ctx.Data
}
if err := tpl.Execute(&result, data); err != nil {
return "", err
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment