Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "not in" #707

Merged
merged 3 commits into from
Jul 20, 2021
Merged

Support "not in" #707

merged 3 commits into from
Jul 20, 2021

Conversation

jasmith-hs
Copy link
Contributor

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 using is 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 is not and the next one is in, 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.

@jasmith-hs jasmith-hs requested a review from jmaroeder July 13, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing not in operator
2 participants