Add not to mean ! #39

Closed
Keats opened this Issue Jun 28, 2016 · 2 comments

Projects

None yet

1 participant

@Keats
Owner
Keats commented Jun 28, 2016 edited

In condition nodes.

Currently there's no way to indicate negation in if/elif.

For booleans we can do:

{% if my_bool == false %}

but that's obviously not ideal and doesn't work for truthy values (truthiness defined there https://github.com/Keats/tera/blob/master/src/context.rs#L86-L99)

We want to be able to express negation like so:

{% if not my_array %} // empty array will result in that if body rendering
{% if not username %} // empty string or null values will result in that if body rendering
{% if user and not user.is_admin %} // render if user exists but is not an admin

The not should be a keyword only used in the condition node but should be reserved globally as a Tera keyword in case we want to expand its use

@Keats Keats changed the title from Add not to mean !, I don't even know if we handle negative right now to Add not to mean ! Jun 29, 2016
@Keats Keats modified the milestone: 0.5 Nov 29, 2016
@Keats
Owner
Keats commented Dec 7, 2016

@Robbepop I've seen your email but the comment doesn't appear in github for some reason.

I clarified the issue a bit more

@Keats
Owner
Keats commented Dec 14, 2016

Anyone working on that? @Robbepop ?

@Keats Keats modified the milestone: 0.6, 0.5 Dec 18, 2016
@Keats Keats added the help wanted label Dec 22, 2016
@Keats Keats added a commit that closed this issue Dec 26, 2016
@Keats Add `not` operator
Closes #39
7714ba7
@Keats Keats closed this in 7714ba7 Dec 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment