From e1b64766b649b71928cdc0541445a2e6cf58586d Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Wed, 7 Dec 2022 21:51:49 -0500 Subject: [PATCH] Fixed the templating system --- app/web/routes.go | 9 +++ views/index.html | 16 +++--- views/item/create.html | 68 +++++++++++++++++++++++ views/item/list.html | 11 ++++ views/layout/footer.html | 5 ++ views/layout/{layout.html => header.html} | 8 +-- 6 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 views/item/create.html create mode 100644 views/item/list.html create mode 100644 views/layout/footer.html rename views/layout/{layout.html => header.html} (79%) diff --git a/app/web/routes.go b/app/web/routes.go index 12ba5b1..a9550b3 100644 --- a/app/web/routes.go +++ b/app/web/routes.go @@ -14,4 +14,13 @@ func RegisterRoutes(f *flamego.Flame) { }) // item list route - lists all of the items in the database + f.Group("/item", func() { + f.Get("/list", func(t template.Template, data template.Data) { + t.HTML(http.StatusOK, "item/list") + }) + + f.Get("/create", func(t template.Template, data template.Data) { + t.HTML(http.StatusOK, "item/create") + }) + }) } diff --git a/views/index.html b/views/index.html index fec188a..0389641 100644 --- a/views/index.html +++ b/views/index.html @@ -1,11 +1,9 @@ -{{ template "layout" . }} +{{ template "layout_header" . }} -{{ define "title" }}Dashboard{{ end }} - -{{ define "content" }} -
-
-

This is a test.

-
+
+
+

This is a test.

-{{ end }} +
+ +{{ template "layout_footer" . }} diff --git a/views/item/create.html b/views/item/create.html new file mode 100644 index 0000000..0d7f85f --- /dev/null +++ b/views/item/create.html @@ -0,0 +1,68 @@ +{{ template "layout_header" . }} + +
+
+

Create new item

+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ + +
+ +
+ + +
+
+ +
+
+ + +
+ +
+ + +
+
+ +
+
+ + +
+ +
+ + +
+
+ + +
+
+
+ +{{ template "layout_footer" . }} diff --git a/views/item/list.html b/views/item/list.html new file mode 100644 index 0000000..b6d5bcb --- /dev/null +++ b/views/item/list.html @@ -0,0 +1,11 @@ +{{ template "layout_header" . }} + +

Create new item

+ + + +{{ template "layout_footer" . }} diff --git a/views/layout/footer.html b/views/layout/footer.html new file mode 100644 index 0000000..a6edaa7 --- /dev/null +++ b/views/layout/footer.html @@ -0,0 +1,5 @@ +{{ define "layout_footer" }} +
+ + +{{ end }} diff --git a/views/layout/layout.html b/views/layout/header.html similarity index 79% rename from views/layout/layout.html rename to views/layout/header.html index efe9d30..6265844 100644 --- a/views/layout/layout.html +++ b/views/layout/header.html @@ -1,11 +1,11 @@ -{{ define "layout" }} +{{ define "layout_header" }} - {{ block "title" . }}{{ end }} | Raven + {{ .title }} | Raven @@ -14,8 +14,4 @@ {{ template "navbar" . }}
- {{ block "content" . }}{{ end }} -
- - {{ end }}