Thymeleaf converts Apostroph into '

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Thymeleaf converts Apostroph into '

This post was updated on .
Hello guys!

i need to build up dynamic the content of a onlick functions in a link tag, like this.
<a href="..." onclick="_gaq.push([ my content]); return true;" title="title">something

The problem ist that in the content of gaq.push functon occurs  Apostroph as Character, see below.

For testing i used to Div Tags, the first one is rendered through Thmyeleaf:
model.put("test", "_gaq.push(['_trackEvent', 'View_switch', 'click_mobile']); return true;");
<div th:text="${test}"></div>

and the second one without thymeleaf:
 <div>_gaq.push(['_trackEvent', 'View_switch', 'click_mobile']); return true;</div>

The result  when i take a look to the Sourcecode of the Site is like that:

rendered with Thymeleaf
<div>_gaq.push([& #39;_trackEvent& #39;, & #39;View_switch& #39;, & #39;click_mobile& #39;]); return true;</div>

The same happens in real when i use th:onclick!

(I insert a whitespace in & #39; because otherwise it is shown correctly as ' here, but in sourcecode it
is as & #39;)

rendered without Thymeleaf (everything is fine)
<div>_gaq.push(['_trackEvent', 'View_switch', 'click_mobile']); return true;</div>

So the Problem is that the Apostroph gets converted in & #039; and this makes later
Problem in the onclick functions because it donĀ“t works in that way.

Thymeleafconfiguration is like that:
        <property name="prefix" value="/WEB-INF/views/html/" />
        <property name="suffix" value=".html" />
        <property name="templateMode" value="LEGACYHTML5" />
        <property name="characterEncoding" value="UTF-8" />
        <property name="cacheable" value="true"/>
        <property name="cacheTTLMs" value="40400"/>
        <property name="order" value="1"/>

Maybe somebody has a idea why this happens.

Thanks for help!



Reply | Threaded
Open this post in threaded view

Re: Thymeleaf converts Apostroph into &#039;