length

The length filter returns the number of items of a sequence or mapping or the length of a string.

Examples

Outputting the length.

{{ variable|length }}

Using the length in a test.

{% if variable|length > 0 %}
...
{% endif %}

 

< Back to the list of filters