The output of:
{% macro foo() -%}
{% macro foo() -%}
1
{%- endmacro %}
{{ foo() }} 2
{%- endmacro %}
{{ foo() }}
{{ foo() }}
Should be:
However, in Jinjava, the output is:
This is because macro functions defined inside of a macro function will override existing macro functions, rather than defining macro functions that exist solely within that scope.
This problem extends beyond just overriding macro functions with the same name. Macro functions defined inside of another macro function should not be usable outside of their defined scope. For example:
{% macro foo() -%}
{% macro bar() -%}
1
{%- endmacro %}
{{ bar() }} 2
{%- endmacro %}
{{ foo() }}
{{ bar() }}
The final bar() should not be calling anything, but the result in Jinjava is: