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

<pre><code>&lt;li&gt;{% if block.destination | length &gt; 25 %}&lt;br /&gt;{% endif %} {{ block.smallCost }}&lt;/li&gt;
</code></pre>

CC BY-SA 3.0
2014-09-05T17:27:03.807Z
Really weird... not sure why that would be the case.
Brad Bell
CC BY-SA 3.0
2014-09-05T16:47:48.427Z
2014-09-05T16:47:48.427Z
simonsweeney
<p>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:</p>

<pre><code>{% for block in entry.pricing %}
    &lt;li&gt;{% if block.destination|length &gt; 25 %}TEST{% endif %}{{ block.smallCost }}&lt;/li&gt;
{% endfor %}
</code></pre>

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

CC BY-SA 3.0
2014-09-05T12:33:14.983Z
That should work as far as I can tell. What happends if you try to output {{ block.destination | length }}?
André Elvan
CC BY-SA 3.0
2014-09-05T16:44:29.563Z
It outputs totally fine, giving the length of the string. It’s just the conditional I can’t figure out?
simonsweeney
<conditional>
Plain Text Length Conditional
# Plain Text Length Conditional

(Asked by: username_0 on 2014-09-05)

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 %}
    {% if block.destination|length > 25 %}TEST{% endif %}{{ block.smallCost }}
{% endfor %}

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

**Tags:** conditional

> **Comments:**
> **username_1**: That should work as far as I can tell. What happends if you try to output {{ block.destination | length }}?  
> **username_0**: It outputs totally fine, giving the length of the string. It’s just the conditional I can’t figure out?  

---

## 1 answers

### Answer by username_0 on 2014-09-05. Score: 1

Turns out it needs the space in the conditional either side of the vertical bar so the code should’ve been:                 
{% if block.destination | length > 25 %}{% endif %} {{ block.smallCost }}

> **Comments:**
> **username_2**: Really weird... not sure why that would be the case.  

---

