[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
commit 8829ee187a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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)
}