I am confused on how to use ! in if condition of nunjucks templates.
Like:
{% if (!pageName) %}
<span>new page</span>
{% endif %}
Currently, I am doing like this:
{% if (pageName) %}
{% else %}
<span>new page</span>
{% endif %}
Use the not keyword.
{% if not pageName %}
<span>new page</span>
{% endif %}
http://mozilla.github.io/nunjucks/templating.html#logic
Also, there's a mailing list that might be a better place for usage questions - https://groups.google.com/forum/?fromgroups#!forum/nunjucks
Thanks @devoidfury
This should be definitely mentioned/referenced in if condition section of the docs. Because most of us are only interested in some parts of docs to do basic stuff like if, for and using variables.
Honestly, it is hard to figure it out that this part is mentioned in the docs.
Many templating basics are not covered in the nunjucks docs; they are "covered" by the note up top that nunjucks is a port of Jinja2, which has detailed docs. That said, I wouldn't turn down any improvements to the nunjucks docs.
nunjucks sucks from its name
penorp
Most helpful comment
Thanks @devoidfury
This should be definitely mentioned/referenced in
ifcondition section of the docs. Because most of us are only interested in some parts of docs to do basic stuff likeif,forand using variables.Honestly, it is hard to figure it out that this part is mentioned in the docs.