1``trim``
2========
3
4The ``trim`` filter strips whitespace (or other characters) from the beginning
5and end of a string:
6
7.. code-block:: twig
8
9    {{ '  I like Twig.  '|trim }}
10
11    {# outputs 'I like Twig.' #}
12
13    {{ '  I like Twig.'|trim('.') }}
14
15    {# outputs '  I like Twig' #}
16
17    {{ '  I like Twig.  '|trim(side='left') }}
18
19    {# outputs 'I like Twig.  ' #}
20
21    {{ '  I like Twig.  '|trim(' ', 'right') }}
22
23    {# outputs '  I like Twig.' #}
24
25.. note::
26
27    Internally, Twig uses the PHP `trim`_, `ltrim`_, and `rtrim`_ functions.
28
29Arguments
30---------
31
32* ``character_mask``: The characters to strip
33
34* ``side``: The default is to strip from the left and the right (`both`) sides, but `left`
35  and `right` will strip from either the left side or right side only
36
37.. _`trim`: https://secure.php.net/trim
38.. _`ltrim`: https://secure.php.net/ltrim
39.. _`rtrim`: https://secure.php.net/rtrim
40