Reputation: 244
I've currently got a string that is stored as html. When I output this to the gsp page I just get plain text.
<g:each in="${fixtureInView.links}">
<h1>Link :${it.encodeAsHTML()}</h1>
</g:each>
Currently displays Link :<a href='http://www.google.co.uk'>Google</a>
and if I change it to decodeHTML it shows <a href='http://www.google.co.uk'>Google</a>
When I try just ${it}
I get Link :<a href='http://www.google.co.uk'>Google</a>
Any ideas?
Upvotes: 2
Views: 4758
Reputation: 244
I've figured this out. If you place raw()
round the variable that is html code, it will let the raw html be rendered as html and not as a string.
Upvotes: 9
Reputation: 1749
In list save your link like this.
"<a href=\"google.com\">Google</a>"
And print it like this.
<g:each in="${fixtureInView.links}">
<h1>Link :${it}</h1>
</g:each>
It will work for you.
Upvotes: 0