Jinja doesn't support this pattern:
{% macro inner %}
inner before
{{ caller() }}
inner after
{% endmacro %}
{% macro outer %}
outer before
{% call inner() %}
{# attempt to call outer caller() in inner caller(), which should be "my_awesome_content" #}
{{ caller() }}
{% endcall %}
outer after
{% endmacro %}
{% call outer() %}
my_awesome_content
{% endcall %}
This is intentional.
However, there is a suggested workaround that looks like this:
{% macro outer %}
outer before
{# declare variable storing outer caller #}
{% set caller_ = caller %}
{% call inner() %}
{# use outer caller from declared variable #}
{{ caller_() }}
{% endcall %}
outer after
{% endmacro %}
With askama, this does currently not work, because the generated code attempts to use the field caller in the template's struct - which obviously doesn't (and probably also shouldn't ?) exist. I assume this would need special handling.
Would it be possible to support this?
Jinja doesn't support this pattern:
This is intentional.
However, there is a suggested workaround that looks like this:
With askama, this does currently not work, because the generated code attempts to use the field
callerin the template's struct - which obviously doesn't (and probably also shouldn't ?) exist. I assume this would need special handling.Would it be possible to support this?