Play Framework [1.2.4]:Escape HTML in view layer

Go To StackoverFlow.com

0

I have a requirement to highlight a part of text based on certain criteria. I am identifying the text to be highlighted in my controller and sending the updated text (along with embedded styles) to the view layer.

I have an object - obj, with obj.text = "Welcome. Hi Dude";

When i use ${obj.Text} in the view layer. The following is displayed as a text...

Welcome. Hi Dude";

Instead...is there way to make the text render as a HTML, meaning just display "Welcome.Hi Dude"?

Note: I am using groovy template

Thanks, Karthik

2012-04-04 20:58
by Karthik


1

You need to use the Raw extension:

 ${obj.text.raw()}

Will produce HTML that is not escaped by the groovy template

2012-04-04 21:10
by mguymon
Yep. That worked fine. Thank - Karthik 2012-04-12 21:46
Ads