Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrap template with a parent layout using thymeleaf

i just decieded to start a little project with spring-boot and thymeleaf.

thymeleaf itself looks awesome until now, but my question is what is the best way to have one e.g. layout.html that brings the basic layout of the page

like
- common css inclusions
- common js inclusions
- basic structure (eg 2/3 column layout)

that is wrapped arround the content of the single pages (view blog post, view comments, view image in gallery, and so on) that i dont need to carry the common stuff into all templates.

until now the only way i found is using fragment inclusions but i'm not sure if this is the correct approach to get a full structure arround the template i want to render for the current request

like how would i get a <div class="content"></div> arround my template?

i hope someone can help.

thanks in advance

like image 373
Dodge Avatar asked Nov 09 '13 10:11

Dodge


1 Answers

You have couple of choices: Tiles Extension, Layout Dialect - you can find both in Ecosystem page here: http://www.thymeleaf.org/ecosystem.html

And native approach (without any extension) described in this comment:

http://blog.codeleak.pl/2013/11/is-it-worth-upgrading-to-thymeleaf-21.html?showComment=1383817035384#c5722173744814267184

I hope it helps.

like image 102
Rafal Borowiec Avatar answered Sep 17 '22 20:09

Rafal Borowiec