From d65480c5ec2e5a47dee717fe73c9151d4b025b61 Mon Sep 17 00:00:00 2001 From: clawbot Date: Sun, 1 Mar 2026 16:34:33 -0800 Subject: [PATCH] fix: template rendering returns empty pages (closes #18) Reorder template.ParseFS arguments so the page template file is listed first. Go's template package names the template set after the first file parsed. When htmlheader.html was first, its content (entirely a {{define}} block) became the root template, which is empty. By putting the page file first, its {{template "base" .}} invocation becomes the root action and the page renders correctly. --- internal/handlers/handlers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 269fd18..55dadb1 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -37,9 +37,13 @@ type Handlers struct { // parsePageTemplate parses a page-specific template set from the embedded FS. // Each page template is combined with the shared base, htmlheader, and navbar templates. +// The page file must be listed first so that its root action ({{template "base" .}}) +// becomes the template set's entry point. If a shared partial (e.g. htmlheader.html) +// is listed first, its {{define}} block becomes the root — which is empty — and +// Execute() produces no output. func parsePageTemplate(pageFile string) *template.Template { return template.Must( - template.ParseFS(templates.Templates, "htmlheader.html", "navbar.html", "base.html", pageFile), + template.ParseFS(templates.Templates, pageFile, "base.html", "htmlheader.html", "navbar.html"), ) }