templates
◊(flower.reflect/root)
page templates
Templates in flower work similarly to other SSGs. A template is a file in the templates/ directory. Any page in your site can be embedded into a template.
flower determines which template to use in the following way:
- if your page has a
template: xxxkey,templates/xxxis used. - if your page has no
templatekey,templates/default.htmlis used. - if your page has a
template: nullkey, no template at all is used and the page is emitted as-is.
This logic can be overridden by creating a custom transformers/embed.clj file. See overriding defaults for more info.
creating new templates
Templates are almost exactly the same as pages, except that they have an injected content variable. content holds your page, rendered as HTML. To change whether your page is rendered before embedding (e.g. if you have a .md markdown template), override the default expressions/transform_sorter.clj so that embed comes before markdown. To change the name of the injected variable, override the default transformers/embed.clj.
embedding
flower ships with an expressions.meta/embed function in the defaults. This can be used to embed templates in other templates. For example, this will call the skeleton.html template with an injected content variable:
◊(def body)«
<p>this is my page!</p>
»
◊(embed "skeleton.html" {'content body})
Notice that this still uses ◊ sunflower syntax. That's because you can write normal HTML before or after the embed call if you need more flexibility.