Refactor: Centralize template context using unified TemplateData struct
- Introduced models.TemplateData for shared user/context state - Moved context construction logic into handlers/template_context.go - Simplified helpers.TemplateContext to accept structured data - Restored and organized template helper functions - Updated affected handlers (main.go, draw_handler.go, notifications.go) - Improved scalability and separation of concerns in template rendering
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"synlotto-website/handlers"
|
||||
"synlotto-website/helpers"
|
||||
"synlotto-website/models"
|
||||
)
|
||||
@@ -19,7 +18,7 @@ func NewDraw(db *sql.DB) http.HandlerFunc {
|
||||
context["Page"] = "new_draw"
|
||||
context["Data"] = nil
|
||||
|
||||
tmpl := template.Must(template.New("").Funcs(handlers.TemplateFuncs()).ParseFiles(
|
||||
tmpl := template.Must(template.New("").Funcs(helpers.TemplateFuncs()).ParseFiles(
|
||||
"templates/layout.html",
|
||||
"templates/topbar.html",
|
||||
"templates/new_draw.html",
|
||||
|
||||
Reference in New Issue
Block a user