开发者

java web playframework: how to ignore Evaluating Expression in a Template?

开发者 https://www.devze.com 2023-01-28 00:55 出处:网络
In view (may be Application/index.html), I had the content like: ... <div>${don\'t need evaluate this content} </div>

In view (may be Application/index.html), I had the content like:

...
<div>${don't need evaluate this content} </div>
...

I don't want Play! evaluate it, only display absolutely this content on screen, so how can I do it ?

Update:

Thank Loic and Niels, I have just checked them, both solutions:

#{verbatim}${don't need evaluate this content}#{/verbatim}

and

<div>'开发者_StackOverflow${don't need evaluate this content}' </div>

didn't work!

Note that, I use XML in response type.


I managed to get this working using the following

<div>&#36;{don't need evaluate this content}</div>


The best practice is to use the verbatim tag:

#{verbatim}${don't need evaluate this content}#{/verbatim}


From my groovy experience I would guess to use simple quotes so

<div>'${don't need evaluate this content}' </div>

But it's not tested. Perhaps \$ works too. At least &#36; instead of $ should work.


All above didn't work in multilines.
Solution:

${"""  ANY
THING 
IN HERE"""}

""" is here-doc expression in Groovy and PHP.
''' is also here-doc without evaluation.

so, we can also do %{print(''' ${test} ''')}%

0

精彩评论

暂无评论...
验证码 换一张
取 消