blob: a852e102e1f1c1cc7b0607b347850c37cee3321c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package views
import (
"embed"
"html/template"
"io"
)
//go:embed **/*.html.tmpl
var fs embed.FS
func Get(path string) (*template.Template, error) {
return template.ParseFS(fs, path+".html.tmpl")
}
func Render[T any](w io.Writer, path string, data T) error {
tmpl, err := Get(path)
if err != nil {
return err
}
return tmpl.Execute(w, data)
}
|