Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use renderFlat inside of the RenderFilter #1159

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

jasmith-hs
Copy link
Contributor

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

@jasmith-hs jasmith-hs added the bug label Feb 16, 2024
@jasmith-hs jasmith-hs merged commit d576527 into master Feb 23, 2024
4 checks passed
@jasmith-hs jasmith-hs deleted the render-filter-no-extends-roots branch February 23, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant