diff options
Diffstat (limited to 'pkg/app/handler/home/utils.go')
-rw-r--r-- | pkg/app/handler/home/utils.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pkg/app/handler/home/utils.go b/pkg/app/handler/home/utils.go new file mode 100644 index 0000000..5f6e0b5 --- /dev/null +++ b/pkg/app/handler/home/utils.go @@ -0,0 +1,34 @@ +// miscellaneous utility functions used for the landing page of the application + +package home + +import ( + "glsamaker/pkg/models" + "glsamaker/pkg/models/users" + "html/template" + "net/http" +) + +// renderIndexTemplate renders all templates used for the landing page +func renderHomeTemplate(w http.ResponseWriter, user *users.User) { + templates := template.Must( + template.Must( + template.New("Show"). + ParseGlob("web/templates/layout/*.tmpl")). + ParseGlob("web/templates/home/*.tmpl")) + + templates.ExecuteTemplate(w, "home.tmpl", createPageData("home", user)) +} + +// createPageData creates the data used in the template of the landing page +func createPageData(page string, user *users.User) interface{} { + return struct { + Page string + Application *models.GlobalSettings + User *users.User + }{ + Page: page, + Application: models.GetDefaultGlobalSettings(), + User: user, + } +} |