I'm having difficulties including braces {
}
in a Handlebars template so that it didn't interfere with Handlebars syntax.
Specifically, I want to have a template like this:
{{{sometag}}}
Except that I want the first and the last braces to be rendered literally, rather than be a part of Handlebar's "non-escaped expression" syntax.
For now, the shortest portable syntax I could come up with is {{#with "{"}}{{.}}{{/with}}
, so that the template that I want would look like:
{{#with "{"}}{{.}}{{/with}}{{sometag}}{{#with "}"}}{{.}}{{/with}}
I could use HTML entities (like https://stackoverflow.com/a/16278085/3088208 suggests), or insert an HTML comment after the initial {
and before the final }
, but these solutions, while practical, depend on HTML which makes them limited.
P. S. Found a duplicate question: Escaping curly brackets standing next to expression in handlebars
Have you tried { {{~sometag~}} }
? As I understand the "specification" and your question, it should do what you want: The outer braces are single and will be quoted verbatim, but the adjacent white space should be removed because of the tildes.