I'm trying to use Freemarker in conjunction with jQuery Templates.
Both frameworks use dollar sign/curly brackets to identify expressions for substitution (or as they're called in freemarker, "interpolations") , e.g. ${person.name}
.
So when I define a jQuery Template with expressions in that syntax, Freemarker tries to interpret them (and fails).
I've tried various combinations of escaping the ${
sequence to pass it through Freemarker to no avail - \${
, \$\{
, $\{
, etc.
Inserting a freemarker comment in between the dollar and the curly (e.g. $<#-- -->{expression}
) DOES work - but I'm looking for a more concise and elegant solution.
Is there a simpler way to get a Freemarker template to output the character sequence ${
?
I can confirm that the
is the correct way as an example.
So I kinda full example will look like
and the output will be :
In the case when you want to use non-raw strings so that you can escape double quotes, apostrophes, etc, you can do the following:
Imagine that you want to use the string ${Hello}-"My friend's friend" inside of a string. You cannot do that with raw strings. What I have used that works is:
I have not escaped the apostrophe since I used double quotes.