I understand the concept, but I don't understand the syntax.
I'm going to use the example used on their site
{% macro render_dialog(title, class='dialog') -%}
<div class="{{ class }}">
<h2>{{ title }}</h2>
<div class="contents">
{{ caller() }}
</div>
</div>
{%- endmacro %}
{% call render_dialog('Hello World') %}
This is a simple dialog rendered by using a macro and
a call block.
{% endcall %}
What will be the output?
sub-question (because I'm hella confused on how this works): Are you allowed to only have 1 caller per macro?
This is the output:
<div class="dialog">
<h2>Hello World</h2>
<div class="contents">
This is a simple dialog rendered by using a macro and
a call block.
</div>
</div>
So when we call render_dialog we pass 'Hello World' as title, when it reach caller()
it passes the contents of the call
block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With