Skip to main content

Hi,

We’re setting up a number of templates for use in post-purchase flows. Some of these templates have conditional statements within the markup that determine what text to show. Here is an example:

{% if person|lookup:'hs_cust_id' > 0 %}
<p>SOME MARKUP FOR PPL WITH THAT CUSTOM FIELD</p>
{% else %}
<p>Default markup</p>
{% endif %}

See that &gt; above? That’s supposed to read ‘{% if person|lookup:'hs_cust_id' > 0 %}’ but every time I (or someone else on the team) makes a change to the template, it auto-escapes it to &gt; .

This happens whether it’s me editing the source code, or someone else using the rich text editor.

Tried to workaround by changing to: {% if person|lookup:'hs_cust_id' &gt;= 1 %}...but you can see what it did to >=.

I’m going to rewrite the template by using the show/hide logic on the ‘Display’ tab for the section, as that doesn’t get auto-formatted, but could this be raised as an issue?

Many thanks,

Gareth

Hi, I just want to add that we are experiencing this too, and hope Klaviyo will see this post :)


We’ve experienced this issue as well… Typing conditional code into text blocks is not straightforward! 


We have a few custom django filters for math comparisons. They’re not documented at https://developers.klaviyo.com/en/docs/glossary_of_variable_filters but I’ll ask our docs team to add them.

Filter Name

Description

Example Syntax

Example Rendering

gt

Use this filter to return the value of the expression "item is greater than value" (item > value) where item is passed first and value is passed second.

{% if 3|gt:2 %}

<p>3 is greater than 2</p>

{% endif %}

 

{% if 2|gt:3 %}

<p>2 is greater than 3</p>

{% endif%}



 

AD_4nXcFQloNO5CGhtIq90bZsljVQOfVcikXms6QJMnos31-ycA1xnas6Zg-gnILTsnhXGtX3iPuqTDqeFj1aS6RtNXB_g3rAC9brwnsjRsz0SsXiiQHvShdYQYnTCzQxILHIjLluyiJDmBZlJZfrpw8KYpOfxg?key=OYxZ8WLD13gJj67YrSpTDA

gte

Use this filter to return the value of the expression "item is greater than or equal to value"  (item >= value) where item is passed first and value is passed second.

{% if 2|gte:2 %}

<p>2 is greater than or equal to 2</p>

{% endif %}

 

{% if 1|gte:2 %}

<p> 1 is greater than or equal to 2</p>

{% endif %}

AD_4nXdyUI1AB7V4C8kuqSPe8fn6to90vWX3nlST7kuAGVrSpcKhZsbgbanITxf2ej-8uK1tlFFRfK7ozYe1Pmc51O0b0wWSEM1FtIVc4ppFX8VCnAfLI3Ca7uegbyIHTYY3QvrPT9bh9bWKMT5P2vKUgqlST1E?key=OYxZ8WLD13gJj67YrSpTDA

lt

Use this filter to return the value of the expression "item is less than value" (item < value) where item is passed first and value is passed second.

{% if 2|lt:3 %}

<p>2 is less than 3</p>

{% endif %}

 

{% if 3|lt:2 %}

<p>3 is less than 2</p>

{% endif %}

AD_4nXfE3c0Kl2bYlRpV0KFsrl0JWPm7tBD1bg9LPWFuj7usperS9fl1hNUTO5dODQix36QYIajPKxDLOafE0st7o3VKHwu2dL_y790EJs5ok3LbuGNT-RF3jZFunXp22KFolDPZn6phea5xNU3xgdEwUvMJ9Q?key=OYxZ8WLD13gJj67YrSpTDA

lte

Use this filter to return the value of the expression "item is less than or equal to value" (item <= value) where item is passed first and value is passed second.

{% if 2|lte:2 %}

<p>2 is less than or equal to 2</p>

{% endif %}

 

{% if 3|lte:2 %}

<p>3 is less than or equal to 2</p>

{% endif %}

AD_4nXfNmo1Ve1-WIw-xDPflVMpo4eh0qtqZx3VzvxkEFbWEZjw_sPTaOksCO83HKARyg9H-t2ei4SDRyea1zcjtKE2UFBp8skGX23S2KsVbKRuaDnCTuuwPWd2mYHrrEq3iZ98mqA8Vona5RpyEPMmVk-rutw?key=OYxZ8WLD13gJj67YrSpTDA


@dartacus @Mathilde, thanks for flagging! We have filed a bug internally for our Engineering team to take a closer look at what’s going on here


@saulblum @Kim Strauch thanks both for the helpful replies. Was able to use |gt:0 to get the template to work as we wanted (although marketing have since changed the flow logic anyway so we won’t be using it now). I’ll note down the filters for future use, as this’ll definitely come up again.