tulip/pages/pages.go
2023-09-06 22:20:09 +01:00

25 lines
423 B
Go

package pages
import (
"embed"
_ "embed"
"html/template"
"io"
)
var (
//go:embed *
embeddedTemplates embed.FS
pageTemplate *template.Template
)
func LoadPageTemplates() (err error) {
pageTemplate, err = template.New("pages").ParseFS(embeddedTemplates, "*.go.html")
return
}
func RenderPageTemplate(wr io.Writer, name string, data any) error {
return pageTemplate.ExecuteTemplate(wr, name+".go.html", data)
}