control/info: Setup template inheritance

This commit is contained in:
Tom Wiesing 2022-10-19 19:39:04 +02:00
parent e5cd57cb7d
commit dd7be3f520
No known key found for this signature in database
12 changed files with 768 additions and 758 deletions

View file

@ -27,8 +27,11 @@ type Assets struct {
// MustParse parses a new template from the given source
// and registers the Asset functions to it.
// See [Assets.RegisterFuncs].
func (assets *Assets) MustParse(value string) *template.Template {
return template.Must(assets.RegisterFuncs(template.New("")).Parse(value))
func (assets *Assets) MustParse(t *template.Template, value string) *template.Template {
if t == nil {
t = template.New("")
}
return template.Must(assets.RegisterFuncs(t).Parse(value))
}
// RegisterFuncs registers three new template functions called "JS", "CSS" and "json".