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.
Fixes #640 and #705
We currently have support for the
in
operator, which handles collection membership in strings, lists, and maps, but we don't support the negation of this operation yet in jinjava. The negation (not in
) is supported in Jinja, and the closest we have to this is by usingis not in
. This, however does not support strings as they are not iterable. The bug in 705 is caused by a faulty check that prevents the logic from working on strings.The approach I went with overrides the
cmp
method, adding logic to the default case where if the current symbol isnot
and the next one isin
, it uses a new CollectionNonMembershipOperator that returns the opposite of CollectionMembershipOperator."not in" is unique in Jinja https://jinja.palletsprojects.com/en/3.0.x/templates/#logic which is why I am handling it with a new operator, rather than doing a generic implementation with
not
before any comparison operator.