dscl
dscl

Reputation: 1626

How to output ${expression} in FreeMarker that contains HTML AS HTML

In my data model myVar contains <b>hello</b> and when I bring it like this ${myVar} the output I get is literally <b>hello</b> rather than hello.

Any idea how to correct this?

Upvotes: 1

Views: 417

Answers (1)

ddekany
ddekany

Reputation: 31162

Certainly you have HTML escaping on, so try <#noescape>${myvar}</#noescape>.

Update: Since 2.3.24 a new kind of auto-escaping was introduced, which doesn't use #escape, and hence nor #noescape. When that's used, write ${myvar?no_esc} to avoid escaping. Or, you can put the value into the data-model already as a TemplateHTMLOutputModel (created with HTMLOutputFormat.fromMarkup(myString)), and then FreeMarker will know without ?no_esc that it need not be escaped.

Upvotes: 2

Related Questions