Please note that if you want to distinguish the undefined value from the zero value in the number type field, you need to do:
//this test will be true only on undefined values {% if !field and field!==0 %} // note the double = !!. indeed in swig and in js !undefined and !0 are both true values // this one will be true for undefined and 0 value fields {% if !field %}
source share