ultraq / thymeleaf-layout-dialect

A dialect for Thymeleaf that lets you build layouts and reusable templates in order to improve code reuse

Home Page:https://ultraq.github.io/thymeleaf-layout-dialect/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thymeleaf Layout Dialect vs. Thymeleaf Fragments

LiviruRMIT opened this issue · comments

commented

The Thymeleaf layout dialect provides the ability to create layouts and reusable templates. However, it seems that similar results can be achieved using Thymeleaf fragments, as demonstrated in their official documentation (https://www.thymeleaf.org/doc/tutorials/3.1/usingthymeleaf.html#layout-inheritance). This raises the question: What advantages does the Thymeleaf layout dialect offer over Thymeleaf fragments? Are there any specific functionalities or features that cannot be replicated using Thymeleaf fragments?

It's been a while since I compared the two approaches, but I think they're equivalent in that everything the layout dialect does Thymeleaf's built-in fragments can do too and vice versa. I think the main difference is conceptual in how you like to think about your pages: the layout dialect treats it more like inheritance whereas the built-in fragments is more like composition, and so each's features are created in those directions.