refactor: common base template for pages

will allow to add common header and stuff
This commit is contained in:
efim
2023-11-13 05:25:02 +00:00
parent b1f2e896b9
commit 1297fcf35d
8 changed files with 140 additions and 55 deletions

View File

@@ -196,7 +196,8 @@ func roomPageRoute(
fmt.Printf("all checks for room %s passed with %+v", roomName, session)
templFile := "templates/room.gohtml"
tmpl := template.Must(template.ParseFS(templateFs, templFile))
baseFile := "templates/base.gohtml"
tmpl := template.Must(template.ParseFS(templateFs, templFile, baseFile))
type GestureData struct {
Name string
@@ -210,15 +211,21 @@ func roomPageRoute(
})
}
pageData := struct {
contentData := struct {
Room rooms.Room
Gestures []GestureData
}{
Room: room,
Gestures: gesturesData,
}
data := pageData{
Base: baseData{
Title: "room-lala-from-base",
},
Content: contentData,
}
err = tmpl.Execute(w, pageData)
err = tmpl.ExecuteTemplate(w, "full-page", data)
if err != nil {
log.Printf("/room/%s my error in executing template, huh\n %s", roomName, err)
}