From 6f755be6cf5a7cdff5283b7bdfbd794d3f4f3beb Mon Sep 17 00:00:00 2001 From: Chris kerr Date: Mon, 27 May 2024 21:28:02 -0400 Subject: [PATCH] refactor template views into own directory --- src/routes/template.go | 12 ++++++------ web/views/{ => template}/#footer.html | 0 web/views/{ => template}/#header.html | 0 web/views/{ => template}/#layout.html | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename web/views/{ => template}/#footer.html (100%) rename web/views/{ => template}/#header.html (100%) rename web/views/{ => template}/#layout.html (100%) diff --git a/src/routes/template.go b/src/routes/template.go index 1d45647..a534019 100644 --- a/src/routes/template.go +++ b/src/routes/template.go @@ -9,16 +9,16 @@ type PageData struct { Title string } -func renderTemplate(w http.ResponseWriter, data PageData, specificTemplate string) { +func renderTemplate(w http.ResponseWriter, data PageData, view string) { // List of common templates - commonTemplates := []string{ - "web/views/#layout.html", - "web/views/#header.html", - "web/views/#footer.html", + layout := []string{ + "web/views/template/#layout.html", + "web/views/template/#header.html", + "web/views/template/#footer.html", } // Append the specific template for the route - templates := append(commonTemplates, specificTemplate) + templates := append(layout, view) // Parse all templates tmpl, err := template.ParseFiles(templates...) diff --git a/web/views/#footer.html b/web/views/template/#footer.html similarity index 100% rename from web/views/#footer.html rename to web/views/template/#footer.html diff --git a/web/views/#header.html b/web/views/template/#header.html similarity index 100% rename from web/views/#header.html rename to web/views/template/#header.html diff --git a/web/views/#layout.html b/web/views/template/#layout.html similarity index 100% rename from web/views/#layout.html rename to web/views/template/#layout.html