I'm trying to output the following from within a liquid template:
{{ example }}
Obviously, Liquid sees this as a variable named example
and tries to do substitution. I'm trying to find out how I can output the actual braces.
So far, I've found one method that works, but it's incredibly ugly:
{{ '{example'|prepend:'{' }}}}
Yeah, told you it was gross.
Here are other things I've tried:
{{{ example }}} # outputs '}' {{{{ example }}}} # outputs '}}' \{\{ example \}\} # outputs '\{\{ example \}\}'
Any advice here?
Curly brackets are commonly used in programming languages such as C, Java, Perl, and PHP to enclose groups of statements or blocks of code.
To escape curly braces and interpolate a string inside the String. format() method use triple curly braces {{{ }}} . Similarly, you can also use the c# string interpolation feature instead of String. format().
In programming, curly braces (the { and } characters) are used in a variety of ways. In C/C++, they are used to signify the start and end of a series of statements. In the following expression, everything between the { and } are executed if the variable mouseDOWNinText is true. See event loop.
"Curly braces can be used to represent the number of repetitions between two numbers. The regex {x,y} means "between x and y repetitions of something". Hence {0,1} is the same thing as ?. If the first number is missing, it is taken to be zero.
You can also use raw:
{% raw %} ...lots of liquid code goes here and it doesn't get interpreted... {% endraw %}
What about using the numeric HTML entities {
and }
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 }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With