如何使用单一&多枝的评论线

时间:2016-04-12 08:44:09

标签: symfony twig

我是twig项目的新成员。我需要评论这个内容:像//或/ ** /那样如何在树枝上使用评论?

    {%if role=3 %}
<div class="col-md-6">
        <div class="form-group">
           <label class="control-label">&nbsp;</label>
           <select multiple class="form-control"  id="path_attachment" name="path_attachment[]"></select>
        </div>
</div>
{% else %}
<div class="col-md-6"></div>
{% endif %}

4 个答案:

答案 0 :(得分:2)

{# Commented Code in Twig #}

希望它会对你有所帮助。

答案 1 :(得分:2)

twig命令关键字是#。在{#中使用并以#}结尾。以下是您需要的答案。

    {#%if role=3 %}
<div class="col-md-6">
        <div class="form-group">
           <label class="control-label">&nbsp;</label>
           <select multiple class="form-control"  id="path_attachment" name="path_attachment[]"></select>
        </div>
</div>
{% else %}
<div class="col-md-6"></div>
{% endif %#}

答案 2 :(得分:1)

您还可以使用IDE /编辑器配置快捷方式,以便注释多行。 在PhpStrom中,我使用 Ctrl + b 来执行此操作。

答案 3 :(得分:0)

评论:)

注释掉一行或多行代码(或一行的一部分)

使用 {# ..... #} 语法。

例如:

单行注释:

{# This will be a comment #}

该行的某些部分:

<p>You can also comment out {# part of a line #}.</p>

多行注释:

{# This will be a 
multi-line
comment. 
#}

注释不仅可用于编写有关代码的注释。您还可以导致代码块不被执行。任何位于注释标签之间的 Twig 代码都不会被执行或输出。

{# The following code will not be executed and nothing will be outputted
{% if category.posts %}
    This category has posts
{% endif %}
#}