Including Template Ability

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

Including Template Ability

Doug
Hi,
Does Thymeleaf allow developers to include templates in another template?
I ask because this is a common situation where you need to create a page template with common header, nav and footer. The main content will then be inserted into the template.

Overall, I like Thymeleaf's direction and its philosophy.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Including Template Ability

danielfernandez
Administrator
Hi,

Yes, you can include other templates :-). Have a look at chapter 8 ("Including and Removing") in the "Using Thymeleaf" tutorial: http://www.thymeleaf.org/usingthymeleaf.html

You can include templates in three ways:

1. Include complete templates (complete files)
2. Include fragments of templates (that you specify by adding a "th:fragment" attribute to the included template).
3. Include fragments of templates by specifying these fragments with an XPath expression (for when you cannot modify the included templates (e.g. a corporate header server or similar).

Regards,
Daniel.