templates: Share fragments
This commit is contained in:
parent
dd7be3f520
commit
d64e6f8ec3
12 changed files with 111 additions and 93 deletions
|
|
@ -1,29 +1,19 @@
|
|||
package info
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/lazy"
|
||||
)
|
||||
|
||||
//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(
|
||||
base("info_components.html"),
|
||||
var componentsTemplate = static.AssetsComponentsIndex.MustParseShared(
|
||||
"info_components.html",
|
||||
componentsTemplateString,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue