Partials allows you to move some shared templates parts like header or footer into separate file and easily reuse them across multiple templates.
Partial template is mostly like regular template. Mean you can use expressions and helpers. But partials have some restrictions. Please read them mindfully to avoid errors:
templates/partials/
folder inside your website bucket.embed_partial
helper inside partial templates.Let's imagine we want to move footer to partial template.
So first of all we need to create partial template (templates/partials/footer.html
) that have code in like this:
<footer>
{{website.domain}} | All rights reserved | 2017
</footer>
That's all! We now can use this partial template in any other template.
We can add it to the templates/index.html
:
... all index.html content
{{embed_partial 'footer'}}
Partial have access to any variables defined in the parent. So if you want to pass some parameters into it, you can use set helper.
property.html
{{set 'page_url' (compose_url property website.url_format_property)}}
{{embed-partial 'header'}}
partials/header.html
{{page_url}}