Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape template syntax in templates

I am making a page in my Play app that talks about how to make Play app pages. (Very meta :P)

I couldn't find anything in the Play Framework documentation that explains how to escape Play's template syntax in a template. Does anyone know how to do this?

like image 767
Will Hains Avatar asked Dec 09 '22 02:12

Will Hains


1 Answers

Lets say you want to display ${name} as HTML text and not let play render a value for variable name then the answer to the question can be found when letting play compile ${"$"} in the template.

Play produces an error stating:

 illegal string body character after dollar sign; solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}"

This actually means that if you want to display ${name} you should write the following

${"\${name}"}

Try this, it works!

like image 63
guy mograbi Avatar answered Feb 13 '23 08:02

guy mograbi