help me~~i'm in hurry, problem in migration from 2.x to 3.x

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

help me~~i'm in hurry, problem in migration from 2.x to 3.x

tom.wang
my 2.x html using thymeleaf and jsrender,they work well

<script type="text/x-jsrender" id="rowTemplate"> <img th:src="@{/resources/css/images/xiala.png}" /> <li th:if="${#httpSession.getAttribute('currentUser')!=null and #httpSession.getAttribute('currentUser').hasPermission(16)}" name="cancelPublish" value="{{attr:id}}">cancel</li> </script>
now because of the issue of performance,i change thymeleaf from 2.x to 3.x
i get a big improvement , and i like it, but the old template doesn't work.

the img tag works after i changed it to below
<img src="[[${#httpServletRequest.contextPath + '/resources/css/images/xiala.png'}]]" />

but how about the th:if ?

please help and thank a lot
Reply | Threaded
Open this post in threaded view
|

Re: help me~~i'm in hurry, problem in migration from 2.x to 3.x

Zemi
Administrator
Hello,

all Thymeleaf 2 template code should work on version 3 without modification (although, for performance reasons, it's better to remove th:inline attributes).

Are you getting an error? Which code is behaving differently?

Regards,
  Zemi

Reply | Threaded
Open this post in threaded view
|

Re: help me~~i'm in hurry, problem in migration from 2.x to 3.x

tom.wang
hi, my problem is , in 2.x, thymeleaf expression in the <script type="text/x-jsrender" id="rowTemplate">...</script> will be parsed, but the same code has not been parsed since i changed to 3.x
Reply | Threaded
Open this post in threaded view
|

Re: help me~~i'm in hurry, problem in migration from 2.x to 3.x

Zemi
Administrator
Hi Tom,

Ok, now I understand the issue.

The problem is that, at this moment, Thymeleaf 3 does not parse the content of a script tag if it doesn't have the type text/template.

So maybe you could try to put that value and then changed it with th:type. Something like

   <script type="text/template" th:type="text/x-jsrender" ...>

Regards,
  Zemi