2

Wondering how to write a conditional that was dependent on the length of a plain text field within a matrix field. I have something like:

{% for block in entry.pricing %}
    <li>{% if block.destination|length > 25 %}TEST{% endif %}{{ block.smallCost }}</li>
{% endfor %}

Where I’m trying to add TEST if the length of the string of block.destination is more than 25.

simonsweeney
  • 399
  • 3
  • 9

1 Answers1

1

Turns out it needs the space in the conditional either side of the vertical bar so the code should’ve been:

<li>{% if block.destination | length > 25 %}<br />{% endif %} {{ block.smallCost }}</li>
simonsweeney
  • 399
  • 3
  • 9