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

@ -2,6 +2,7 @@ package info
import (
_ "embed"
"html/template"
"net/http"
"time"
@ -9,9 +10,22 @@ import (
"github.com/FAU-CDI/wisski-distillery/pkg/lazy"
)
//go:embed "html/components.html"
//go:embed "html/base.html"
var baseTemplateString string
var baseTemplate = template.Must(template.New("base.html").Parse(baseTemplateString))
func base(name string) *template.Template {
clone := template.Must(baseTemplate.Clone())
clone.Tree.Name = name
return clone
}
//go:embed "html/info_components.html"
var componentsTemplateString string
var componentsTemplate = static.AssetsComponentsIndex.MustParse(componentsTemplateString)
var componentsTemplate = static.AssetsComponentsIndex.MustParse(
base("info_components.html"),
componentsTemplateString,
)
type componentsPageContext struct {
Time time.Time