Credit to devdocs.io

twig

twig

trim

New in version 1.6.2: The trim filter was added in Twig 1.6.2.

The trim filter strips whitespace (or other characters) from the beginning and end of a string:

{{ '  I like Twig.  '|trim }}

{# outputs 'I like Twig.' #}

{{ '  I like Twig.'|trim('.') }}

{# outputs '  I like Twig' #}

Note

Internally, Twig uses the PHP trim function.

Arguments

  • character_mask: The characters to strip

© 2009–2016 by the Twig Team
Licensed under the three clause BSD license.
The Twig logo is © 2010–2016 SensioLabs
http://twig.sensiolabs.org/doc/filters/trim.html