What is the difference between {% vs {% - in twig?

as you can see here https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig some of the if conditions are written as:

{% if condition %}

but others are written as:

{%- if condition -%}

my code works fine with both versions. unfortunately, this is not possible for Google to answer, since google doesn’t really like the alphanumeric characters in the request, nor did I find the link in the twig documentation.

My question is: what is the difference between the two?

What is the meaning of dash in {%- ?

+7
twig
source share
1 answer

This is due to branch space management. Using the space management modifier in your tags, you can trim leading and / or trailing spaces. Here are the docs .

+10
source share

All Articles