Show each page's own title in the browser tab (closes #117)
check / check (push) Successful in 3m12s

parsePageTemplate parsed the page file before htmlheader.html. A later
definition of a template name replaces an earlier one (an empty one
never does), so htmlheader.html's {{block "title"}} replaced every
page's {{define "title"}} and every tab read "Webhooker". The page file
is now parsed last, into a set named after it, so it stays the entry
point.

A new test renders every page template and checks its title; the
"Webhooker" fallback is checked on htmlheader.html alone, since every
page declares a title.

Model: opus-5-5
This commit is contained in:
2026-10-02 23:03:39 +00:00
parent f282c6363d
commit 89556c413b
2 changed files with 115 additions and 5 deletions
+8 -5
View File
@@ -110,22 +110,25 @@ type Handlers struct {
// parsePageTemplate parses a page-specific template set from the
// embedded FS. Each page template is combined with the shared
// base, htmlheader, navbar and notice templates, and with any further
// files the page includes. The page file must be listed first so that
// its root action ({{template "base" .}}) becomes the template set's
// entry point.
// files the page includes. The set is named after the page file, so
// the page's root action ({{template "base" .}}) is its entry point.
//
// The page file is parsed last because a later definition of a name
// replaces an earlier one: the page's {{define "title"}} must replace
// the {{block "title"}} fallback in htmlheader.html.
func parsePageTemplate(
pageFile string, included ...string,
) *template.Template {
files := append([]string{
pageFile,
"base.html",
"htmlheader.html",
"navbar.html",
"notice.html",
}, included...)
files = append(files, pageFile)
return template.Must(
template.ParseFS(templates.Templates, files...),
template.New(pageFile).ParseFS(templates.Templates, files...),
)
}