Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the hyphen mean for a block in Twig like in {% block body -%}?

Tags:

twig

When generating a CRUD in a Symfony2 application with Doctrine commands, generated Twig template content is defined within a Twig block this way:

{% block body -%}  {% endblock %} 

What does the hyphen in -%} mean? It works fine without the hyphen and I could not find anything similar in the Twig documentation.

like image 378
Michaël Perrin Avatar asked Jun 25 '13 13:06

Michaël Perrin


People also ask

What is block in twig?

Blocks are used for inheritance and act as placeholders and replacements at the same time. They are documented in detail in the documentation for the extends tag. Block names must consist of alphanumeric characters, and underscores. The first char can't be a digit and dashes are not permitted.


1 Answers

The -%} means to trim whitespace.

See the Whitespace Control section of the docs.

like image 74
Dave Newton Avatar answered Sep 30 '22 23:09

Dave Newton