[feature] Add page-specific class per template (#3814)

* [feature] Add page-specific class per template

* cheeky bit cheaper
This commit is contained in:
tobi
2025-02-20 15:09:28 +01:00
committed by GitHub
parent a03a35a5d6
commit 8829ee187a
7 changed files with 14 additions and 6 deletions

View File

@ -236,6 +236,16 @@ func templatePage(
obj map[string]any,
) {
const pageTmpl = "page.tmpl"
// Render given template inside the page.
obj["pageContent"] = template
// Inject specific page class by trimming
// ".tmpl" suffix. In the page template
// (see page.tmpl) this will be appended
// with "-page", so "index.tmpl" for example
// ends up with class "page index-page".
obj["pageClass"] = template[:len(template)-5]
c.HTML(code, pageTmpl, obj)
}