You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
584 B

package engine
import (
"fmt"
html "html/template"
"gitoa.ru/go-4devs/mime"
"gitoa.ru/go-4devs/templating/engine"
"gitoa.ru/go-4devs/templating/loader"
)
const Name = "gohtml"
func Parser(source loader.Source) (engine.Template, error) {
tpl, err := html.New(source.Name()).Parse(source.Data())
if err != nil {
return nil, fmt.Errorf("parse html:%w", engine.ErrNotSupport)
}
return engine.NewTemplate(tpl.Name(), tpl.Execute), nil
}
func New(opts ...engine.Option) *engine.Engine {
return engine.New(Name, Parser, append(opts, engine.WithFormats(mime.ExtHTML))...)
}