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