连字符对于 Twig 中的块意味着什么,例如 {% block body -%}?意味着什么、字符、body、Twig

2023-09-07 00:10:12 作者:盲人椅

当使用 Doctrine 命令在 Symfony2 应用程序中生成 CRUD 时,生成的 Twig 模板内容在 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 %}

-%} 中的连字符是什么意思?没有连字符就可以正常工作,我在 Twig 文档中找不到类似的东西.

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

推荐答案

-%} 表示修剪空白.

请参阅文档的 空白控制部分.