How to escape Twig delimiters in a Twig template?

前端 未结 3 1416
不知归路
不知归路 2020-12-09 07:34

Twig uses the {{ }}, {% %}, {# #} delimiters.

But how can I display {{ }} in a Twig template? I\'m not talking ab

3条回答
  •  爱一瞬间的悲伤
    2020-12-09 07:59

    The easiest way is to output the variable delimiter ({{) by using a variable expression:

    {{ '{{' }}
    

    Alternatives (used when you have to escape too much) are raw (verbatim since 1.12) blocks:

    {% raw %}
        
      {% for item in seq %}
    • {{ item }}
    • {% endfor %}
    {% endraw %}

    Actually, it's quite well documented.

提交回复
热议问题