Taekmin Kim
Taekmin Kim

Reputation: 151

thymeleaf render partially on spring boot

I am using thymeleaf on spring boot for web application development.

Maybe i have to make many (html) pages. But thymeleaf doesn't seem to support partial rendering.

I want something like 'yield' in ruby on rails.

Upvotes: 1

Views: 3117

Answers (2)

Suisse
Suisse

Reputation: 3613

How about fragments in thymeleaf?

<body>
    <div th:include="fragments/footer :: footer">...</div>
</body>

http://www.thymeleaf.org/doc/articles/layouts.html

Upvotes: 0

Dave Syer
Dave Syer

Reputation: 58094

It looks like this is a question about views that share layouts using Thymeleaf. So the link that the OP shared in a comment is one way to handle it as a DIY solution. The Thymeleaf Layout Dialect is my preferred solution since it doesn't require me to write any code. Spring Boot makes it easy - just include "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect" on your classpath. There's a sample in the Spring Boot codebase.

Upvotes: 3

Related Questions