How do you comment out in Liquid?

青春壹個敷衍的年華 提交于 2019-12-20 10:16:10

问题


What is the correct way to comment out in the Liquid templating language?


回答1:


In Liquid you comment out using the {% comment %} and {% endcomment %} tags:

{% comment %} This is a comment in Liquid {% endcomment %}

It doesn't matter if the comment is inline or a block comment.

{% comment %}
    This is a block comment in Liquid
{% endcomment %}



回答2:


Liquid allows you to leave un-rendered code inside a Liquid template by using the {% comment %} and {% endcomment %} tags.

Input:

Anything you put between {% comment %} and {% endcomment %} tags
is turned into a comment.

Output:

Anything you put between  tags
is turned into a comment.

Reference documentation: Comment tag in Liquid




回答3:


In the liquid, using comment tag enclose the text to be commented inside the comment tag

{%comment%}
Text to be commented
{%endcomment%}



回答4:


In liquid, you use {% comment %} and {% endcomment %} tags:

{% comment %} This would be commented out {% endcomment %}

You can also use it in block:

{% comment %}
    This would also be commented out
{% endcomment %}

If the {% comment %} and {% endcomment %} tags would comment anything, including HTML elements and such:

 {% comment %}
    <div class="commented_out">
    <p>This whole div would be commented out</p>
    </div>
{% endcomment %}


来源:https://stackoverflow.com/questions/27007323/how-do-you-comment-out-in-liquid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!