1``map`` 2======= 3 4.. versionadded:: 2.10 5 6 The ``map`` filter was added in Twig 2.10. 7 8The ``map`` filter applies an arrow function to the elements of a sequence or a 9mapping. The arrow function receives the value of the sequence or mapping: 10 11.. code-block:: twig 12 13 {% set people = [ 14 {first: "Bob", last: "Smith"}, 15 {first: "Alice", last: "Dupond"}, 16 ] %} 17 18 {{ people|map(p => "#{p.first} #{p.last}")|join(', ') }} 19 {# outputs Bob Smith, Alice Dupond #} 20 21The arrow function also receives the key as a second argument: 22 23.. code-block:: twig 24 25 {% set people = { 26 "Bob": "Smith", 27 "Alice": "Dupond", 28 } %} 29 30 {{ people|map((last, first) => "#{first} #{last}")|join(', ') }} 31 {# outputs Bob Smith, Alice Dupond #} 32 33Note that the arrow function has access to the current context. 34 35Arguments 36--------- 37 38* ``arrow``: The arrow function 39