Easy whitespace trimming with Twig
Categories
When using the Twig templating engine for PHP you might have used the trim filter to trim away any possible existing blanks at the beginning and end of a string:
{{ ' I like Twig. '|trim }}
{# outputs 'I like Twig.' #}
Another way to trim out whitespaces is by using the – modifier:
<li>
{{- value }} </li>
{# outputs '<li>no spaces </li>' #}