Spark Java Views Using Thymeleaf - SiteMesh Like Layouts
In the last post we looked at how Thymeleaf handles reusable layouts. A reddit user enlightened me about an open source ‘dialect’ for Thymeleaf that makes it behave in a similar manner to SiteMesh. It’s documented pretty well, but...

Yeah, documentation can be boring sometimes, so I thought I’d put together a quick post on how that would look in the Spark Java application I’ve been working with. It works well, but it suffers from an inability to pass model variables to the layout template. That’s something that SiteMesh can handle (although in a less-than-elegant manner in my opinion) and in my view it is almost deal breaker. Something as simple as a nav menu that is common across all pages will ultimately require some dynamic data, and if we’re going to need to th:insert the fragment on every page, then what are we really gaining by using this style of layout template? I’ll add how I’d think this could be handled at the end of this post, but first let’s look at how to implement this dialect in the project.










\