simplify template parsing

jocadbz
Joca 2026-02-20 14:37:49 -03:00
parent 2c7634da43
commit 7fa8634bcb
Signed by: jocadbz
GPG Key ID: B1836DCE2F50BDF7
1 changed files with 21 additions and 15 deletions

36
main.go
View File

@ -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)
}