Exemplo n.º 1
0
func RenderTemplateString(tmplString string, name string, out io.Writer, context interface{}) (err error) {
	var templ templatesystem.Template
	templ, err = Config.TemplateSystem.ParseString(tmplString, name)
	if err != nil {
		return
	}

	// context = append(context, Config)
	return templ.Render(out, context)
}
Exemplo n.º 2
0
func RenderTemplate(filename string, out io.Writer, context interface{}) (err error) {
	filePath, found, _ := FindTemplateFile(filename)
	if !found {
		return errs.Format("Template file not found: %s", filename)
	}

	var templ templatesystem.Template
	templ, err = Config.TemplateSystem.ParseFile(filePath)
	if err != nil {
		return
	}

	// context = append(context, Config)
	return templ.Render(out, context)
}