Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1121
Adds Jinja's
{% with %}...{% endwith %}scoped assignment tag. Right now this fails withUnknown tag: with:Behavior follows Jinja:
setinside the block, are gone afterendwith, and outer variables with the same name come back{% with a = 1, b = a %}givesbthe outera{% with %}with no assignments just opens a scopeHow it works:
WithTagsplits the assignments on top-level commas (commas and=inside strings, brackets and comparisons like==/<=are left alone), enters a scope, runs a multi-target set ({% set a, b = x, y %}) through the registered set tag, then renders the body. Going through set means eager execution gets the existing deferred-assignment handling.EagerWithTagrenders the block in a child context and, if anything stayed deferred, wraps the output withwrapInChildScopethe same wayEagerForTagdoes:If
setis disabled in the config, awiththat assigns adds a DISABLED error and renders nothing (a bare{% with %}still works), so it can't be used to get around a disabled set tag.Tests:
WithTagTest: scoping, shadowing, outer-scope evaluation, nesting, loop variables, commas/operators inside values, the example from the issue, and syntax errors (bad target, missing=, missing value, duplicate names)EagerWithTagTest: runs all of the above in eager mode, plus deferred cases that render the eager output a second time and check the final resultWithTagDisabledSetTest: default and eager modemvn verifypasses locally (2272 tests, plus checkstyle/pmd/spotbugs/spotless). Note that the checked-in wrapper is Maven 3.6.2, but git-commit-id-maven-plugin 9 needs 3.6.3+, so I ran it with Maven 3.9.9.