package gohtml import ( "context" "fmt" html "html/template" "gitoa.ru/go-4devs/templating" "gitoa.ru/go-4devs/templating/engine" gohtml "gitoa.ru/go-4devs/templating/gohtml/engine" "gitoa.ru/go-4devs/templating/loader" ) const Name = gohtml.Name var htm = gohtml.New() func init() { templating.AddEngine(htm) } // Loader set new loader. This function is not thread-safe. func Loader(in loader.Loader) { htm = htm.WithLoader(in) } func Must(template *html.Template, err error) { MustRegister(html.Must(template, err)) } func MustRegister(template *html.Template) { if rerr := Register(template); rerr != nil { panic(rerr) } } func Register(template *html.Template) error { if err := htm.Add(context.Background(), engine.NewTemplate(template.Name(), template.Execute)); err != nil { return fmt.Errorf("gohtml loader:%w", err) } return nil }