frontend: fix bugs according to monsterTable

This commit is contained in:
Patryk Hegenberg 2023-12-06 11:42:44 +01:00
parent b82e138c4d
commit 309ade3e72
4 changed files with 13 additions and 8 deletions

View file

@ -1,6 +1,7 @@
package handlers
import (
"ddServer/model"
"embed"
"html/template"
"log"
@ -8,7 +9,7 @@ import (
)
// MainHandler
func MainHandler(content embed.FS) http.HandlerFunc {
func MainHandler(content embed.FS, monsters *[]model.Monster) http.HandlerFunc {
log.Print("MainHandler called")
return func(w http.ResponseWriter, r *http.Request) {
tmpl, err := template.ParseFS(content, "templates/main.html", "templates/monsterForm.html", "templates/monster.html", "templates/monsterTable.html")
@ -17,8 +18,12 @@ func MainHandler(content embed.FS) http.HandlerFunc {
return
}
mu.Lock()
defer mu.Unlock()
err = tmpl.ExecuteTemplate(w, "main", map[string]interface{}{
"Title": "Dungeons & Dragons Monster Generator",
"Title": "Dungeons & Dragons Monster Generator",
"Monsters": *monsters,
})
if err != nil {
log.Printf("Template execution error: %v\n", err)