~bigbes/sr-ht-ecore

ref: 996577debafad52175a58dad9819376a0ba1887c sr-ht-ecore/chrome/templates.go -rw-r--r-- 689 bytes
996577de — Eugene Blikh pages: the shared page set, buffered render and error page 10 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package chrome

import (
	"embed"
	"html/template"
)

//go:embed templates/chrome.tmpl
var templateFS embed.FS

// Attach parses the shared chrome partials ("srht-nav", "srht-env-banner")
// into t, so a service layout can invoke them. Call it once per template set,
// before the layout that references the partials is executed.
func Attach(t *template.Template) (*template.Template, error) {
	return t.ParseFS(templateFS, "templates/chrome.tmpl")
}

// MustAttach is Attach for the common wire-up-at-startup path, where a parse
// failure is a programmer error.
func MustAttach(t *template.Template) *template.Template {
	t, err := Attach(t)
	if err != nil {
		panic(err)
	}
	return t
}