as can be seen 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 perfectly fine with both versions. unfortunately its impossible to google the answer as google doesn't like no alphanumeric chars in query very much, also i did not find any reference in twig documentation.
my question is, whats the difference between those two?
whats the meaning of the dash in {%-
?
Twig tags are control structures that control the flow of the templates. They consist of conditionals (i.e. if/elseif/else), for loops, as well as blocks. Tags appear inside a pair of {% %} blocks. The closing {% %} block is "end" followed by the tag name.
twig command keyword is #. using inside of {# and end with #}. below is your needed answer.
It is related to twig's whitespace control. By using the whitespace control modifier on your tags, you can trim leading and/or trailing whitespace. Here's the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With