From 55c6a3504229f04eb1d842686ffb06b714afbe06 Mon Sep 17 00:00:00 2001 From: X201 Date: Sun, 26 May 2024 20:38:49 -0400 Subject: [PATCH] header seperated from view --- src/routes/root.go | 2 +- web/views/#header.html | 7 +++++++ web/views/#layout.html | 1 + web/views/index.html | 6 ------ 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 web/views/#header.html diff --git a/src/routes/root.go b/src/routes/root.go index 90205ff..950afeb 100644 --- a/src/routes/root.go +++ b/src/routes/root.go @@ -14,7 +14,7 @@ func RootHandler(w http.ResponseWriter, r *http.Request) { Title: "Home Page", } - tmpl, err := template.ParseFiles("web/views/#layout.html", "web/views/index.html") + tmpl, err := template.ParseFiles("web/views/#layout.html", "web/views/index.html", "web/views/#header.html") if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/web/views/#header.html b/web/views/#header.html new file mode 100644 index 0000000..91b34c5 --- /dev/null +++ b/web/views/#header.html @@ -0,0 +1,7 @@ +{{define "header"}} +
+

+ Welcome to My GO Web App Framework {{.Title}} +

+
+ {{end}} \ No newline at end of file diff --git a/web/views/#layout.html b/web/views/#layout.html index 8490629..b1c5619 100644 --- a/web/views/#layout.html +++ b/web/views/#layout.html @@ -10,6 +10,7 @@ + {{template "header" .}} {{template "view" .}} diff --git a/web/views/index.html b/web/views/index.html index 94e4e0d..2b4eaf6 100644 --- a/web/views/index.html +++ b/web/views/index.html @@ -1,10 +1,4 @@ {{define "view"}} -
-

- Welcome to My GO Web App Framework {{.Title}} -

-
-