So that extends roots are not prematurely processed. Similar to how expression nodes use interpreter.renderFlat when doing nested interpretation, the RenderFilter must do the same, otherwise it will process the extends roots early.
What this looks like is that the new test I added's output looks like this before this fix:
I am the extension body
You should never see this text in the output!
Base footer
The reason this bug happens is because:
We encounter the {% extends 'filter/render/base.jinja' %} tag, and add the base.jinja as an extends root
We encounter the extended {% block body %}
We use the |render filter
We then try to process the extends root.
We find {% block body %} and {% block footer %} and resolve them to the extended body and the base footer as that is all we've seen at this point
We pop the extends root
We return the output of base.jinja with the extended body substituted in
We encounter the extended {% block footer %}
We try to process the extends root, there are none anymore so we act like our original template didn't extend anything and we output it, including its (previously resolved) blocks
What should happen (what now happens after this PR) is:
We encounter the {% extends 'filter/render/base.jinja' %} tag, and add the base.jinja as an extends root
We encounter the extended {% block body %}
We use the |render filter
We encounter the extended {% block footer %}
We try to process the extends root
We find {% block body %} and {% block footer %} and resolve them to the extended body and the extended footer as we've seen both of those already
We pop the extends root
We return the output of base.jinja with the extended body and footer substituted in
So that extends roots are not prematurely processed. Similar to how expression nodes use
interpreter.renderFlat
when doing nested interpretation, theRenderFilter
must do the same, otherwise it will process the extends roots early. What this looks like is that the new test I added's output looks like this before this fix:The reason this bug happens is because:
{% extends 'filter/render/base.jinja' %}
tag, and add thebase.jinja
as an extends root{% block body %}
|render
filter{% block body %}
and{% block footer %}
and resolve them to the extendedbody
and the basefooter
as that is all we've seen at this pointbase.jinja
with the extendedbody
substituted in{% block footer %}
What should happen (what now happens after this PR) is:
{% extends 'filter/render/base.jinja' %}
tag, and add thebase.jinja
as an extends root{% block body %}
|render
filter{% block footer %}
{% block body %}
and{% block footer %}
and resolve them to the extendedbody
and the extendedfooter
as we've seen both of those alreadybase.jinja
with the extendedbody
andfooter
substituted in