refactor template views into own directory

This commit is contained in:
Chris kerr 2024-05-27 21:28:02 -04:00
parent 34fe9b4992
commit 6f755be6cf
4 changed files with 6 additions and 6 deletions

View File

@ -9,16 +9,16 @@ type PageData struct {
Title string Title string
} }
func renderTemplate(w http.ResponseWriter, data PageData, specificTemplate string) { func renderTemplate(w http.ResponseWriter, data PageData, view string) {
// List of common templates // List of common templates
commonTemplates := []string{ layout := []string{
"web/views/#layout.html", "web/views/template/#layout.html",
"web/views/#header.html", "web/views/template/#header.html",
"web/views/#footer.html", "web/views/template/#footer.html",
} }
// Append the specific template for the route // Append the specific template for the route
templates := append(commonTemplates, specificTemplate) templates := append(layout, view)
// Parse all templates // Parse all templates
tmpl, err := template.ParseFiles(templates...) tmpl, err := template.ParseFiles(templates...)