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