Skip to content

Improve deferred word filtering - #1040

Merged
jasmith-hs merged 2 commits into
masterfrom
improve-deferred-word-filter
Mar 30, 2023
Merged

Improve deferred word filtering #1040
jasmith-hs merged 2 commits into
masterfrom
improve-deferred-word-filter

Conversation

@jasmith-hs

Copy link
Copy Markdown
Contributor

So that deferred words that aren't in the combined scope aren't attempted to be reconstructed in the wrong scope

Follow up on #1032

This test demonstrates the problem:

{% set my_list = [] %}
{% set foo %}
{% do my_list.append(deferred) %}a
{% endset %}
{{ my_list }}

We don't want my_list to get reconstructed inside the set tag so we should filter the deferred words that we reconstruct before deferring them to only reconstruct those within the current scope.

Set<String> deferredWordBases = deferredWords
.stream()
.map(w -> w.split("\\.", 2)[0])
.filter(combinedScope::containsKey)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the change, the rest is refactoring duplicated code

@jasmith-hs
jasmith-hs merged commit 3c1852e into masterMar 30, 2023
@jasmith-hs
jasmith-hs deleted the improve-deferred-word-filter branch March 30, 2023 13:57
Sign up for freeto 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

@jasmith-hs