Reputation: 8297
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
Upvotes: 15
Views: 10146
Reputation: 58094
Recent versions of Spring Boot include Thymeleaf with native support for fragments. It's the best option now. Example here.
OLD ANSWER: Spring Boot has out-of-the-box support for the LayoutDialect
(in our opinion it is the best option). You just need to add the right versions of everything to your classpath. There's a sample that uses this approach.
Upvotes: 7
Reputation: 5244
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:
I hope it helps.
Upvotes: 7