~bigbes/sr-ht-ecore

ref: 77b1a8d29ddcc961be32f05736168edc9ade50d3 sr-ht-ecore/chrome/templates.go -rw-r--r-- 689 bytes
77b1a8d2 — Eugene Blikh middleware: the shared cache and panic handling 9 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
}