Add PageHeader.Lang, BodyAttrs, SidebarAttrs escape hatches

Lang: <html lang> override (defaults to "en") for a non-English UI.
BodyAttrs/SidebarAttrs: raw extra attributes spliced into <body> and
the sidebar's <nav> tag, typed template.HTMLAttr (not template.HTML --
the contextual autoescaper requires the attribute-list sentinel type
in this position or it silently drops the value). Needed by yakwui's
Alpine.js-driven collapsible mobile sidebar, which has no other way to
carry x-data state onto a common ancestor of the toggle button and the
sidebar nav.
This commit is contained in:
terminar committed 2026-09-01 09:40:26 +02:00
1 parent c99b000b1d
commit 1c1878cfca
3 files changed
+38 -4

No files matched your search

+6 -3
View File
@@ -43,6 +43,7 @@ type NavItem struct {
type PageHeader struct {
Title string
Name string // lowercase product name, e.g. "yasta"; used in <title> and the footer
Lang string // <html lang="...">; "" defaults to "en"
Brand string // navbar brand text, e.g. "YASTA"
BrandInitial string // single-letter favicon glyph, e.g. "y"
Subtitle string
@@ -63,9 +64,11 @@ type PageHeader struct {
// <body...> and the sidebar's <nav...> tag -- an escape hatch for a
// consuming project's own client-side framework state (e.g. yakwui's
// Alpine.js collapsible sidebar), which the shared markup has no
// generic opinion about.
BodyAttrs template.HTML
SidebarAttrs template.HTML
// generic opinion about. template.HTMLAttr, not template.HTML --
// html/template's contextual autoescaper requires the attribute-list
// sentinel type in this position or it silently drops the value.
BodyAttrs template.HTMLAttr
SidebarAttrs template.HTMLAttr
}
// Renderer holds one independently parsed *template.Template per page: