mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 18:36:53 +00:00
3d1b9a11d8
* 2.x: fixed CS added the key to the map and filter filters added support for iterators removed fn in front of arrow functions changed arrow syntax added "filter", "map", and "reduce" filters simplified code fixed CS bumped version to 2.10 bumped version to 1.41 fixed partial output leak when a PHP fatal error occurs fixed markup in docs
33 lines
694 B
ReStructuredText
33 lines
694 B
ReStructuredText
``join``
|
|
========
|
|
|
|
The ``join`` filter returns a string which is the concatenation of the items
|
|
of a sequence:
|
|
|
|
.. code-block:: twig
|
|
|
|
{{ [1, 2, 3]|join }}
|
|
{# returns 123 #}
|
|
|
|
The separator between elements is an empty string per default, but you can
|
|
define it with the optional first parameter:
|
|
|
|
.. code-block:: twig
|
|
|
|
{{ [1, 2, 3]|join('|') }}
|
|
{# outputs 1|2|3 #}
|
|
|
|
A second parameter can also be provided that will be the separator used between
|
|
the last two items of the sequence:
|
|
|
|
.. code-block:: twig
|
|
|
|
{{ [1, 2, 3]|join(', ', ' and ') }}
|
|
{# outputs 1, 2 and 3 #}
|
|
|
|
Arguments
|
|
---------
|
|
|
|
* ``glue``: The separator
|
|
* ``and``: The separator for the last pair of input items
|