Skip to content

fix: Preserve block tags to preserve reconstruction/execution order#1312

Open
jasmith-hs wants to merge 6 commits intomasterfrom
fix-block-reconstruction
Open

fix: Preserve block tags to preserve reconstruction/execution order#1312
jasmith-hs wants to merge 6 commits intomasterfrom
fix-block-reconstruction

Conversation

@jasmith-hs
Copy link
Copy Markdown
Contributor

Simpler and more accurate fix to the bug that #1307 targeted (in that this also handles deferred modifications).

There is a bug in how reconstructed output is rendered when there are block tags due to the order of execution. Block tags are always evaluated last, even if they'll show up higher in a template

(I use {# \d+ #} in the following examples to show the order in which the lines are evaluated)

Child

{# 1 #}{% extends parent %}
{# 2 #}{% block foo %}
{# 6 #}{{ foo_bar }}
{# 2 #}{% endblock %}

Parent

{# 3 #}{{ 'Hello' }}
{# 4 #}{% block foo %}{% endblock %}
{# 5 #}{% set foo_bar = deferred %}

If reconstructed directly, we'd end up with:

{# 1 #}{{ foo_bar }}
{# 2 #}{% set foo_bar = deferred %}

Which results in foo_bar not being reconstructed in time. However, if we preserve the blocks, we can also preserve the execution order:

{# 1 #}{% block foo %}
{# 3 #}{{ foo_bar }}
{# 1 #}{% endblock %}
{# 2 #}{% set foo_bar = deferred %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants