2024-04-24 00:34:57 +00:00
|
|
|
package frontend
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"html/template"
|
|
|
|
"io/fs"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
//go:embed static
|
|
|
|
static embed.FS
|
|
|
|
Static fs.FS
|
|
|
|
|
|
|
|
//go:embed *.html
|
|
|
|
templatesFS embed.FS
|
|
|
|
Templates *template.Template
|
2024-04-25 19:06:20 +00:00
|
|
|
|
|
|
|
funcs = template.FuncMap{
|
2024-11-23 03:50:18 +00:00
|
|
|
"version": func() string { return "better-zwave-locks v0.x.x aaaaaaaa" },
|
2024-04-25 19:06:20 +00:00
|
|
|
}
|
2024-04-24 00:34:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2024-04-25 19:06:20 +00:00
|
|
|
t := template.New("").Funcs(funcs)
|
|
|
|
|
2024-04-24 00:34:57 +00:00
|
|
|
var err error
|
2024-04-25 19:06:20 +00:00
|
|
|
Templates, err = t.ParseFS(templatesFS, "*")
|
2024-04-24 00:34:57 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
Static, err = fs.Sub(static, "static")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|