Outputting Literal curly braces in Liquid templates

后端 未结 4 597
南旧
南旧 2021-02-05 02:40

I\'m trying to output the following from within a liquid template:

{{ example }}

Obviously, Liquid sees this as a variable named example<

相关标签:
4条回答
  • 2021-02-05 02:46

    You can escape the HTML, for example in a {{var}} you can use \{\{var\}\}, so that way luquid don't process it.

    0 讨论(0)
  • 2021-02-05 02:59

    This is the only thing that worked from me. Lifted from here:

    {{ "{{ this " }}}}
    

    I needed this because I wanted to reference the site global variable from inside a mustache template.

    0 讨论(0)
  • 2021-02-05 03:01

    You can also use raw:

    {% raw %}
    
    ...lots of liquid code goes here and it doesn't get interpreted...
    
    {% endraw %}
    
    0 讨论(0)
  • 2021-02-05 03:03

    What about using the numeric HTML entities &#123; and &#125; for { and } respectively - presumably this is to be output as HTML?

    EDIT: Forgive me, I'm not too familiar with liquid (so this might be very wrong), but can you assign your {{ example }} special value to a variable and output that? May be something like:

    {% assign special = '{{ example }}' %}
    {{ special }}
    
    0 讨论(0)
提交回复
热议问题