1``first`` 2========= 3 4.. versionadded:: 1.12.2 5 The ``first`` filter was added in Twig 1.12.2. 6 7The ``first`` filter returns the first "element" of a sequence, a mapping, or 8a string: 9 10.. code-block:: jinja 11 12 {{ [1, 2, 3, 4]|first }} 13 {# outputs 1 #} 14 15 {{ { a: 1, b: 2, c: 3, d: 4 }|first }} 16 {# outputs 1 #} 17 18 {{ '1234'|first }} 19 {# outputs 1 #} 20 21.. note:: 22 23 It also works with objects implementing the `Traversable`_ interface. 24 25.. _`Traversable`: https://secure.php.net/manual/en/class.traversable.php 26