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

Add test notequalto #510

Closed
wants to merge 1 commit into from
Closed

Add test notequalto #510

wants to merge 1 commit into from

Conversation

brmzkw
Copy link

@brmzkw brmzkw commented Nov 5, 2015

I guess the filters test_test (testing if value) and test_not (testing if not value) would be great additions too.

@ThiefMaster
Copy link
Member

You can already use is not equalto something:

>>> Template('{{ foo is not equalto "bar" }}').render(foo="xxx")
u'True'

If you want the negation of select or selectattr use reject or rejectattr instead.

@brmzkw
Copy link
Author

brmzkw commented Nov 5, 2015

I need to use notequalto in a select filter, such astring.split('/') | select('notequalto', ''). In this case, using is not equalto something doesn't seem possible. Is it?

@mitsuhiko
Copy link
Contributor

Why not use {{ users|rejectattr("email", "equalto", "foo@bar.valid") }}?

@brmzkw
Copy link
Author

brmzkw commented Nov 5, 2015

You save my day. I didn't know rejectattr (or reject in my case) existed. Thanks a lot :)

@brmzkw brmzkw closed this Nov 5, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants