Add PageHeader.BodyAttrs/SidebarAttrs escape hatches

Needed by yakwui's Alpine.js-based collapsible sidebar (x-data on
<body>, :class binding on the sidebar <nav>) -- the shared markup has
no generic opinion about a consumer's own client-side framework state.
This commit is contained in:
terminar committed 2026-08-31 14:13:01 +02:00
1 parent 671d9bd92d
commit c99b000b1d
2 files changed
+10 -2

No files matched your search

+8
View File
@@ -58,6 +58,14 @@ type PageHeader struct {
NavbarRightExtra template.HTML // extra markup rendered after Username/Logout in the navbar's right group
ExtraHeadHTML template.HTML // extra <link>/<script> tags appended to <head>
ExtraBodyHTML template.HTML // extra <script> tags appended before </body>
// BodyAttrs/SidebarAttrs are raw extra attributes (include their own
// leading space, e.g. ` x-data="{ open: true }"`) spliced into
// <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
}
// Renderer holds one independently parsed *template.Template per page:
+2 -2
View File
@@ -10,11 +10,11 @@
<script src="{{.BasePath}}/webui-static/bootstrap.bundle.min.js" defer></script>
{{.ExtraHeadHTML}}
</head>
<body>
<body{{.BodyAttrs}}>
{{template "navbar" .}}
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 col-lg-2 sidebar d-md-block">
<nav class="col-md-2 col-lg-2 sidebar d-md-block"{{.SidebarAttrs}}>
{{template "sidebar" .}}
</nav>
<main class="col-md-10 col-lg-10 ms-sm-auto px-md-4 py-3">