go-web-template/handlers/template.go

31 lines
651 B
Go
Raw Permalink Normal View History

2024-08-25 16:40:48 +02:00
package handlers
import (
"html/template"
"git.vbrandl.net/vbrandl/go-web-template/assets"
)
var indexTemplate *template.Template
var notFoundTemplate *template.Template
type templateData struct {
RequestID string
}
func (app *Application) ParseTemplates() error {
t, err := template.ParseFS(assets.Templates, "public/html/index.html", "public/html/navbar.tmpl", "public/html/footer.tmpl")
if err != nil {
return err
}
indexTemplate = t
t, err = template.ParseFS(assets.Templates, "public/html/notFound.html", "public/html/navbar.tmpl", "public/html/footer.tmpl")
if err != nil {
return err
}
notFoundTemplate = t
return nil
}