Forum Discussion
3 Replies
Sort By
- SeanConnaughto1Qrew CadetFrom what I understand (which may not be fully correct), using {% if variable is defined %} is checking if that variable exists, regardless of having data associated or not.
Using {% if variable %} equates the if statement to a basic true/false, true if there is any data associated, false if nothing is associated (or if the field value is 0). I think the use of {% if variable != '' %} just may not be best practice/correct usage in jinja2, but that is where I may be completely incorrect.
------------------------------
Sean Connaughton
------------------------------- DanielJohnson2Qrew TraineeThanks Sean, that all makes sense.
------------------------------
Daniel Johnson
------------------------------- DanielJohnson2Qrew TraineeI posted this same question on Stack Overflow, and someone suggested:
However, Pipelines wouldn't let me save that, so I tried:{% if c.call_rating not none %} Call Rating: {{c.call_rating}} {% endif %}
And that worked! Not defining the else seems to null the entry if {% if c.call_rating %} is false.{% if c.call_rating %} Call Rating: {{c.call_rating}} {% endif %}
------------------------------
Daniel Johnson
------------------------------