Quantcast

Use 'th:with' and 'layout:decorate' (layout dialect) in html tag

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Use 'th:with' and 'layout:decorate' (layout dialect) in html tag

migueldeblas
If I use this doesn't work:
   <html th:with="baseUrl = ${base.url + '/'}" layout:decorate="~{${baseUrl + 'layout'}}"> 

--> Error: nulllayout doesn't exist.


But if I use this work:
   <html layout:decorate="~{${base.url + '/layout'}}">  *OK*

Is "th:width" incompatible with "th:decorate" (layout dialect)?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use 'th:with' and 'layout:decorate' (layout dialect) in html tag

Metroids
I'm guessing th:with has a lower precedence than layout:decorate.  So it's not that they're incompatible, just that layout:decorate is evaluated before th:with.

http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#attribute-precedence

That being said, I don't think you'll be able to get them to work the way you want. Normally you could do something like this:

<th:block th:with="baseUrl = ${base.url + '/'}">
    <html layout:decorate="~{${baseUrl + 'layout'}}">
    </html>
</th:block>

I don't know if that is what you want though.  I'm not even sure if you can surround html with a th:block.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use 'th:with' and 'layout:decorate' (layout dialect) in html tag

migueldeblas
Yes, I tried it, but I wanted to know if there's a more elegant way.
I have read it but I don't see it. How did you see the preference order of "th:decorate"? I suppose there's general precedence between dialects.
Loading...