Skip to content

Remove meta context vars in regular for loop#1094

Merged
jasmith-hs merged 2 commits intomasterfrom
remove-meta-context-vars-in-regular-for-loop
Jul 25, 2023
Merged

Remove meta context vars in regular for loop#1094
jasmith-hs merged 2 commits intomasterfrom
remove-meta-context-vars-in-regular-for-loop

Conversation

@jasmith-hs
Copy link
Copy Markdown
Contributor

In eager execution, we'll use the default for loop logic first if the collection can be resolved so we need to remove the variables from the meta context variables as we do when running the EagerForTag's logic.

Basically, we weren't doing this when using the regular for loop's logic:

Set<String> removedMetaContextVariables = EagerReconstructionUtils.removeMetaContextVariables(
loopVars.stream(),
interpreter.getContext()
);

Without this change, the eager execution output would look like:

{% for __ignored__ in [0] %}
  {% macro render(content, query) %}
    {% if query %}
      {{ content.foo }}
    {% endif %}
  {% endmacro %}
  {{ render(content, deferred) }}
 // repeated
{% endfor %}

content would not be reconstructed since it would remain considered a meta-context variable, but we need to temporarily remove that status when rendering a for loop {% for content in looper %}

In eager execution, we'll use the default for loop logic first if the collection can be resolved so we need to remove the variables from the meta context variables as we do when running
the EagerForTag's logic
@jasmith-hs jasmith-hs merged commit baf0cc3 into master Jul 25, 2023
@jasmith-hs jasmith-hs deleted the remove-meta-context-vars-in-regular-for-loop branch July 25, 2023 12:29
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.

1 participant