mirror of
https://github.com/1f349/tulip.git
synced 2024-12-22 16:24:10 +00:00
25 lines
423 B
Go
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)
|
|
}
|