package engine import ( "fmt" text "text/template" "gitoa.ru/go-4devs/mime" "gitoa.ru/go-4devs/templating/engine" "gitoa.ru/go-4devs/templating/loader" ) const Name = "gotxt" func Parser(source loader.Source) (engine.Template, error) { tpl, err := text.New(source.Name()).Parse(source.Data()) if err != nil { return nil, fmt.Errorf("parse text:%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.ExtTxt, mime.ExtText))...) }