mg-transport-core/core/template.go

27 lines
588 B
Go
Raw Normal View History

2019-09-04 15:22:27 +03:00
package core
import (
"html/template"
"github.com/gin-contrib/multitemplate"
)
// Renderer wraps multitemplate.Renderer in order to make it easier to use
type Renderer struct {
multitemplate.Renderer
FuncMap template.FuncMap
}
// NewRenderer is a Renderer constructor
func NewRenderer(funcMap template.FuncMap) Renderer {
return Renderer{
Renderer: multitemplate.NewRenderer(),
FuncMap: funcMap,
}
}
// Push is an AddFromFilesFuncs wrapper
func (r *Renderer) Push(name string, files ...string) *template.Template {
return r.AddFromFilesFuncs(name, r.FuncMap, files...)
}