Nunjucks: Set block ignored inside macro

Created on 26 Apr 2016  路  2Comments  路  Source: mozilla/nunjucks

Consider the code:

{% set testA %}foo{% endset %}
Output: {{ testA }}

This returns "Output: foo".

Now:

{% macro module() %}
{% set testB %}bar{% endset %}
Output: {{ testB }}
{% endmacro %}

This returns "barOutput: ".

Anyone else experienced this behavior?

Thanks!


Full disclosure: I'm importing my macro from another file.

bug

Most helpful comment

Workaround:

{% macro module() %}
    {% macro workaround() %}bar{% endmacro %}
    {% set testB = workaround() %}
    Output: {{ testB }}
{% endmacro %}

All 2 comments

I can reproduce this. That's definitely a bug.

Workaround:

{% macro module() %}
    {% macro workaround() %}bar{% endmacro %}
    {% set testB = workaround() %}
    Output: {{ testB }}
{% endmacro %}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Galfour picture Galfour  路  3Comments

thisKai picture thisKai  路  3Comments

mintyPT picture mintyPT  路  4Comments

gaboesquivel picture gaboesquivel  路  4Comments

sudhirbeldar picture sudhirbeldar  路  3Comments