How do you comment out in Liquid?

前端 未结 5 1845
轻奢々
轻奢々 2020-12-29 00:48

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

5条回答
  •  长发绾君心
    2020-12-29 01:45

    If, like me, you are looking for a solution that actually comments out "anything"/everything between the comment tags (as described in the documentation), you can use the {% raw %} tag (in conjuction with the {% comment %} tag if you don't want anything rendered in the browser), e.g.

    {% comment %}
        {% raw %}
            Here is some text that I don't want displayed and
            {% some_liquid_stuff_that_I_don't_want_parsed %}
        {% endraw %}
    {% endcomment %}
    

    will render nothing at all, while

    {% raw %}
        Here is some text that I want displayed but
        {% some_liquid_stuff_that_I_don't_want_parsed %}
    {% endraw %}
    

    will render

    Here is some text that I want displayed but

    {% some_liquid_stuff_that_I_don't_want_parsed %}

    Additional information on this GitHub thread.

提交回复
热议问题