Using {% set %} inside a caller()?
Author: stephenbarkanCreated Jul 27, 2025Updated Jul 27, 2025
Hi! I'm wondering if it might be possible to {% set %} variables inside a caller() for a macro, to effectively create multiple "slots" within the macro. AFAICT, with caller() you usually only get one slot.
My use case:
{% macro section() %}
<section>
{{ caller() }}
<div>{{ leftColumn }}</div>
<div>{{ rightColumn }}</div>
</section>
{% endmacro %}
{% call section() %}
{% set leftColumn %}
This is the left column
{% endset %}
{% set rightColumn %}
This is the right column
{% endset %}
{% endcall %}I would expect it to output
<section>
<div>This is the left column</div>
<div>This is the right column</div>
</section>But it just does this
<section>
<div></div>
<div></div>
</section>Is there a way to set those variables within the call() so they'll fill in the slots? Thank you!
Source: mozilla/nunjucks