Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/srndv2/src/srnd/templates_std.go

28 lines
550 B
Go
Raw Normal View History

package srnd
import (
"bytes"
stdtemplate "html/template"
"io"
)
type stdTemplateDriver struct {
}
func (d *stdTemplateDriver) Render(templ string, obj interface{}, w io.Writer) error {
return stdtemplate.Must(stdtemplate.New("").Parse(templ)).Execute(w, obj)
}
func (d *stdTemplateDriver) RenderString(templ string, obj interface{}) (string, error) {
buff := new(bytes.Buffer)
err := d.Render(templ, obj, buff)
if err == nil {
return buff.String(), nil
}
return "", err
}
func (d *stdTemplateDriver) Ext() string {
return ".tmpl"
}