refactor template views into own directory
This commit is contained in:
parent
34fe9b4992
commit
6f755be6cf
@ -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...)
|
||||||
|
Loading…
Reference in New Issue
Block a user