moved route definition to a map
This commit is contained in:
parent
434708b291
commit
10140231a6
2 changed files with 25 additions and 12 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue