views:

22

answers:

1

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?

+1  A: 

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 }}
w3d
Unfortunately, the output is ultimately going to be within a <script> tag, so using an entity won't work.
Fortes
@Fortes I've updated my answer: can you assign your string with braces to a variable and output that instead?
w3d
A little roundabout, but it works. Thanks!
Fortes
Uh, is this the only way to display Liquid syntax in Liquid itself? I'm trying to display a whole template on a page that is generated with Liquid and it's messed up badly right now. Is there nothing like {{noparsefromhere}}...{{noparsetohere}}?
cringe
@cringe I would agree - there _should_ be a way. But I'm no expert with Liquid I'm afraid! Can you for instance load your entire _sub template_ (that you want to display as-is) into a template variable (without it being parsed) and display your variable in the main template? Or does that still get parsed?
w3d
@w3d Hm, that sounds like a way to do it... I don't know yet if I can load a whole template. But I think it's easier for me to just provide the actual template in source format and link to it directly.
cringe