simplify template parsing
parent
2c7634da43
commit
7fa8634bcb
36
main.go
36
main.go
|
|
@ -363,21 +363,27 @@ func main() {
|
||||||
))
|
))
|
||||||
|
|
||||||
// Parse page-specific templates with unique names
|
// Parse page-specific templates with unique names
|
||||||
tmpl, err = tmpl.ParseFiles(
|
pageTemplates := []string{
|
||||||
filepath.Join(dir, "templates/pages/about.html"),
|
"about.html",
|
||||||
filepath.Join(dir, "templates/pages/board.html"),
|
"board.html",
|
||||||
filepath.Join(dir, "templates/pages/boards.html"),
|
"boards.html",
|
||||||
filepath.Join(dir, "templates/pages/home.html"),
|
"home.html",
|
||||||
filepath.Join(dir, "templates/pages/login.html"),
|
"login.html",
|
||||||
filepath.Join(dir, "templates/pages/news.html"),
|
"news.html",
|
||||||
filepath.Join(dir, "templates/pages/profile.html"),
|
"profile.html",
|
||||||
filepath.Join(dir, "templates/pages/profile_edit.html"),
|
"profile_edit.html",
|
||||||
filepath.Join(dir, "templates/pages/signup.html"),
|
"signup.html",
|
||||||
filepath.Join(dir, "templates/pages/thread.html"),
|
"thread.html",
|
||||||
filepath.Join(dir, "templates/pages/userhome.html"),
|
"userhome.html",
|
||||||
filepath.Join(dir, "templates/pages/chat.html"),
|
"chat.html",
|
||||||
filepath.Join(dir, "templates/pages/preferences.html"),
|
"preferences.html",
|
||||||
)
|
}
|
||||||
|
pagePaths := make([]string, 0, len(pageTemplates))
|
||||||
|
for _, name := range pageTemplates {
|
||||||
|
pagePaths = append(pagePaths, filepath.Join(dir, "templates/pages", name))
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl, err = tmpl.ParseFiles(pagePaths...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error parsing page templates:", err)
|
log.Fatal("Error parsing page templates:", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue