moved route definition to a map

This commit is contained in:
bronku 2025-03-29 08:55:54 +01:00
parent 434708b291
commit 10140231a6
2 changed files with 25 additions and 12 deletions

View file

@ -14,16 +14,15 @@ var templates embed.FS
func (h *Server) loadTemplates() {
h.tmpl = make(map[string]*template.Template)
pages := []string{"orders", "order", "cake", "cakes", "confirmation"}
for _, page := range pages {
for _, page := range h.routes {
tmpl, err := template.ParseFS(templates,
"templates/layout/*.html",
"templates/"+page+".html",
"templates/"+page.template+".html",
)
if err != nil {
log.Fatal(err)
}
h.tmpl[page] = tmpl
h.tmpl[page.template] = tmpl
}
}