N
Novu3w ago
Casper

Liquid syntax in email code editor

Hi I am trying to put a conditional statement in an HTML email template with the code editor, like {% if payload.socials != "" %} <tr> <td colspan="2" valign="middle" id="social"> {{payload.socials}} </td> </tr> {% endif %} However, that throws a syntax error on the 'if' statement. How can I check if my payload.socials parameter is not empty? NB I can check for {% if payload.socials %} but that is true even if payload.socials is "". And if I do not provide a payload.socials, then I get an error that my trigger message does not match the payload scheme (obviously).
2 Replies
Pawan Jain
Pawan Jain3w ago
@Casper Checkout this code. You need to use apostrophes in place of double quotation marks
{% if payload.socials != '' %}
<tr>
<td colspan="2" valign="middle" id="social">
{{payload.socials}}
</td>
</tr>
{% else %}
<tr>
this is else block
</tr>
{% endif %}
{% if payload.socials != '' %}
<tr>
<td colspan="2" valign="middle" id="social">
{{payload.socials}}
</td>
</tr>
{% else %}
<tr>
this is else block
</tr>
{% endif %}
Casper
CasperOP2w ago
Thanks I will try that. Also will try non-required fields.

Did you find this page helpful?