adhocteam / pushup

Pushup is for making modern, page-oriented web apps in Go
https://pushup.adhoc.dev
MIT License
840 stars 30 forks source link

Add sections to layouts #25

Closed paulsmith closed 1 year ago

paulsmith commented 1 year ago

A layout should be able to specify a section, which is a Pushup API and syntax that allows pages to, for example, set the HTML <title> element or similar varying across different pages.

This will need some design iteration, but should look roughly like:

<title>^(Section("title"))</title>

Note the use of an explicit expression (transition symbol followed by balanced parens ^(...))

If a page did not reference the section, it would render as

<title></title>

The layout could alternately do something like

^if SectionSet("title") {
    <title>^(Section("title"))</title>
} else {
    <title>My Pushup site</title>
}

For a default value.

<title>My Pushup site</title>

But a page could write something like:

^section title { <text>Foo</text> }

and get

<title>Foo</title>

Within the { } the HTML parser would be in effect.