~bigbes/sr-ht-ecore

ref: 0dfd1e5d1f4717fd047f6e007a92e5ef504c42cd sr-ht-ecore/chrome/templates.go -rw-r--r-- 689 bytes
0dfd1e5d — Eugene Blikh ci: gitsync mirror webhook for the srht mirror 11 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
}