3 ms·
I've been using Thymeleaf with Spring for a while and almost always exclusively use it with Spring Boot because it's pretty much right out of the box ready to g
by manyxcxi 10y ago
I've been using Thymeleaf with Spring for a while and almost always exclusively use it with Spring Boot because it's pretty much right out of the box ready to go.
I stumbled on it a long time ago because I had the problem of Java devs needing to integrate templates built by front end devs and all the churn that goes along with it.
It uses custom tag attributes like th:href to swap the computed value in on template render so you can have a completely perfect looking HTML/CSS/JS template with the placeholder values without having to convert back and forth. It's just HTML with extra attributes that get ignored when not run through the rendering process.
You can use Spring Expressions, forms, and security with pretty much no configuration, it works awesome.
It supports partials and layouts and all the good stuff you'd want for reuse and it took me about 10 minutes to create a custom dialect for it that lets me use Thymeleaf and Vue.js together very nicely.
I can't recommend Thymeleaf enough.
- kentosi 10y agoOne issue is if you're using Angular. Your html document needs to be xhtml compatible, meaning that an expression like this: <div ng-if="this() && that()" ... Needs to become: <div ng-if="this() && that()" ... If this doesn't bother you (along with > for <, etc) then go ahead.
- manyxcxi 10y agoIt doesn't have to if you write your own dialect for Thymeleaf. You can alter the flow of the output manipulation and validation- it's out of the box that it chokes on the 'weird' stuff being shoved into attribute tags nowadays for JS templates. If you want the unescaped output there are lots of things you can do. I did something similar for Vue.js in about twenty minutes and a few lines of code.