'Mailjet templating - conditional decision when a value in var is (not) null
Is it possible to conditionally check and decide if var:<my_var> is null | not null?
I am might be missing something obvious, but so far did not find how to do it in https://dev.mailjet.com/email/template-language/.
Hacky approach which works:
{% set my_var = var:my_var:"N/A" %}
{% if my_var != "N/A" %}
{{my_var}}
{% endif %}
Solution 1:[1]
This is what we are using too, but I would recommend adding a check for an empty string too.
Mailjet API sometimes doesn't like to accept null properties.
<mj-raw>
{% set my_var = var:my_var:"N/A" %}
{% if my_var != "N/A" and my_var != "" %}
</mj-raw>
... some html ...
<mj-raw>
{% endif %}
</mj-raw>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | peter |