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", 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 { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return 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"> <body class="text-center text-blue-300 bg-gray-800">
{{template "header" .}} {{template "header" .}}
{{template "view" .}} {{template "view" .}}
{{template "footer" .}}
</body> </body>
</html> </html>
{{end}} {{end}}

View File

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