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