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
|
||||
tmpl, err = tmpl.ParseFiles(
|
||||
filepath.Join(dir, "templates/pages/about.html"),
|
||||
filepath.Join(dir, "templates/pages/board.html"),
|
||||
filepath.Join(dir, "templates/pages/boards.html"),
|
||||
filepath.Join(dir, "templates/pages/home.html"),
|
||||
filepath.Join(dir, "templates/pages/login.html"),
|
||||
filepath.Join(dir, "templates/pages/news.html"),
|
||||
filepath.Join(dir, "templates/pages/profile.html"),
|
||||
filepath.Join(dir, "templates/pages/profile_edit.html"),
|
||||
filepath.Join(dir, "templates/pages/signup.html"),
|
||||
filepath.Join(dir, "templates/pages/thread.html"),
|
||||
filepath.Join(dir, "templates/pages/userhome.html"),
|
||||
filepath.Join(dir, "templates/pages/chat.html"),
|
||||
filepath.Join(dir, "templates/pages/preferences.html"),
|
||||
)
|
||||
pageTemplates := []string{
|
||||
"about.html",
|
||||
"board.html",
|
||||
"boards.html",
|
||||
"home.html",
|
||||
"login.html",
|
||||
"news.html",
|
||||
"profile.html",
|
||||
"profile_edit.html",
|
||||
"signup.html",
|
||||
"thread.html",
|
||||
"userhome.html",
|
||||
"chat.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 {
|
||||
log.Fatal("Error parsing page templates:", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue