Skip to content

Commit

Permalink
fix #1 Allow the use of custom template functions
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Dec 20, 2016
1 parent 599adf1 commit 0216d6b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions multitemplate.go
Expand Up @@ -42,6 +42,13 @@ func (r *Render) AddFromString(name, templateString string) *template.Template {
return tmpl
}

func (r Render) AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template {
tname := filepath.Base(files[0])
tmpl := template.Must(template.New(tname).Funcs(funcMap).ParseFiles(files...))
r.Add(name, tmpl)
return tmpl
}

func (r Render) Instance(name string, data interface{}) render.Render {
return render.HTML{
Template: r[name],
Expand Down

0 comments on commit 0216d6b

Please sign in to comment.