How do I escape {{ curly braces }}

How do I escape double curly braces? I want a text that just says:

{{ it's all just a string }}

I can escape the curly braces like this:
{{ '{{' }} hello }}
but this seems like a very unprincipled way to go about this and I am uncomfortable leaving stuff like this in a production app.

I tried the following, all of which don't work:

 \{\{ it's all just a string \}\}
 \{{ it's all just a string \}}
 {{ "{{ it's all just a string }}" }}

EDIT: put the above in a code block because otherwise (of course!) my escape characters got escaped :wink:

What's the recommended way of doing this?

Hi @Lychee,

You can do it with backslashes. Like this:

{{ `\{\{ it's all just a string \}\}` }}

I'm not using quotes/single quotes, I'm using backticks to wrap the string, otherwise you'd need to escape your apostrophe's as well.

image

image

Alternatively, you could use &123; and &125; instead, which will render the same way, and then you don't have to put them in curly braces in the first place.

image

3 Likes