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 && and || ? #622

Closed
atian25 opened this issue Dec 27, 2015 · 6 comments
Closed

support && and || ? #622

atian25 opened this issue Dec 27, 2015 · 6 comments

Comments

@atian25
Copy link
Contributor

atian25 commented Dec 27, 2015

{% if list && list.length>0 %} and {{ someVal || "test"}}

@ricordisamoa
Copy link
Contributor

#344 (comment)

We do aim to have as close API/syntax to jinja as much as possible, so adding && || !, although familiar to javascript, would potentially polute and confuse, having multiple ways of doing the same thing.

@carljm
Copy link
Contributor

carljm commented Dec 27, 2015

Agreed, we don't need redundant syntax for things that already exist.

@carljm carljm closed this as completed Dec 27, 2015
@LeeKowalkowski
Copy link

The documentation for if (https://mozilla.github.io/nunjucks/templating.html#if) says "It behaves exactly as javascript's if behaves".

@ghostcode
Copy link

// And Snippet
{% if (VARIABLE > 10) and (VARIABLE < 20) %}
    // 
{% endif %}

// Or Snippet
{% if (VARIABLE == 10) or (VARIABLE == 20) %}
    //
{% endif %}

@kangzj
Copy link

kangzj commented Jun 27, 2019

The documentation for if (https://mozilla.github.io/nunjucks/templating.html#if) says "It behaves exactly as javascript's if behaves".

I was mislead by the document as well.

@murtuzaalisurti
Copy link

I use the shorthand if operator {{ if truthy foo else bar }}

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

No branches or pull requests

7 participants