Fixed
This release fixes an issue with using variables inside Components.
You can now use both the page
object and the locals=""
attribute to render data inside a Component.
For example:
---
title: "Component test"
---
<extends src="src/layouts/master.html">
<block name="template">
<component src="src/components/example.html" locals='{"foo": "bar"}'>
page.title passed inside component: {{ page.title }}
</component>
</block>
</extends>
<!-- src/components/example.html -->
page.title accessed in component: {{ page.title }}
data passed in locals="" attribute: {{ foo }}
<content></content>
Will render:
page.title accessed in component: Component test
data passed in locals="" attribute: bar
page.title passed inside component: Component test
Escaping expressions inside a component
Because expressions are now evaluated twice (once in component, once for the entire template), escaping expressions inside a component needs to be done like this:
<!-- escape a single expression -->
@@{{ foo }}
<!-- escaping a block -->
<raw>
@{{ foo }}
</raw>