Introduction

The length filter is used to obtain the number of elements in a list or the number of characters in a string. It is useful for determining the size of arrays, objects, or strings, which can be essential for flow control and data formatting.

Example of use

Example of how to use the length filter to get the number of elements in a list and the number of characters in a string:

{# Getting the number of elements in a list #}
{{ ['Apple', 'Banana', 'Orange']|length }}

{# Getting the number of characters in a string #}
{{ 'Hello, World!'|length }}

Example Output Code