seperate footer into template

This commit is contained in:
X201 2024-05-26 21:42:53 -04:00
parent 55c6a35042
commit 9f741eecbe
4 changed files with 7 additions and 5 deletions

View File

@ -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", "web/views/#header.html")
tmpl, err := template.ParseFiles("web/views/#layout.html", "web/views/index.html", "web/views/#header.html", "web/views/#footer.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return

5
web/views/#footer.html Normal file
View File

@ -0,0 +1,5 @@
{{define "footer"}}
<footer>
<p>&copy; 2024 My Web App</p>
</footer>
{{end}}

View File

@ -12,6 +12,7 @@
<body class="text-center text-blue-300 bg-gray-800">
{{template "header" .}}
{{template "view" .}}
{{template "footer" .}}
</body>
</html>
{{end}}

View File

@ -14,8 +14,4 @@
<a href="/example">Another Example Route can be found here</a>
</section>
</main>
<footer>
<p>&copy; 2024 My Web App</p>
</footer>
{{end}}