-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
in reference to this https://handlebarsjs.com/guide/expressions.html#escaping-handlebars-expressions
first of all, linking directly does not work (at least in Firefox..), so to see what I'm talking about you must do this:
- visit this page https://handlebarsjs.com/guide/
- on the left side navigation menu, under Language Guide, click Expressions
- either scroll all the way down the page, or, in the right side "On this page" menu, click "Escaping Handlebars expres..."
it looks like this
it says this:
Handlebars content may be escaped in one of two ways, inline escapes or raw block helpers. Inline escapes created by prefixing a mustache block with . Raw blocks are created using {{{{ mustache braces.
the documentation text states that quadruple staches are used to create raw blocks, but then the example shows that there is a built-in block helper for raw blocks - it seems the latter is correct, the former does not seem to work. in both cases, it seems like a pretty useless feature.. maybe an example that demonstrates a real-world use case would be good?
I stumbled upon this while trying to use handlebars to render source code for another templating language which also uses brackets to delimit the code blocks (it is "Zephyr" which is a template language for a large newsletter service called Sailthru) - it frustratingly does not support white space between the delimiting brackets and the operands so I had a bit of trouble with getting the brackets sorted out, this "escaping" feature seemed like it would be useful here but ended up not helping me at all.
I needed to escape the final closing brace in this line because handlebars chokes on it - it confuses the three braces at the end for a mismatch of the two braces that opened the expression
{if {{variable_variable_name}}}but the escape of a single brace does not work either, it renders the back slash
{if {{variable_variable_name}}\}I ended up doing something like this:
{if {{concat variable_variable_name '}'}}which is pretty ugly.
I think this would have also worked, not any better
{if {{variable_variable_name~}} }would have been nice if the brace matching was more tolerant, or escaping a closing brace was possible