Forum Discussion
DanielJohnson2
4 years agoQrew Trainee
Thanks Sean, that worked. I was hoping for something a little cleaner. I think you're previous suggestion to insert a conditional before that step is probably better, just for the sake of readability in the UI.
Thanks!
------------------------------
Daniel Johnson
------------------------------
Thanks!
------------------------------
Daniel Johnson
------------------------------
DanielJohnson2
4 years agoQrew Trainee
One more question. What's the logic behind {% if variable %}? Is there a difference between:
{% if variable %}
{% if variable is defined%}
{% if variable != '' %}
?
------------------------------
Daniel Johnson
------------------------------
{% if variable %}
{% if variable is defined%}
{% if variable != '' %}
?
------------------------------
Daniel Johnson
------------------------------
- SeanConnaughto14 years agoQrew 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
------------------------------ - DanielJohnson24 years agoQrew TraineeThanks Sean, that all makes sense.
------------------------------
Daniel Johnson
------------------------------ - DanielJohnson24 years agoQrew 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
------------------------------