rocker
rocker copied to clipboard
Consider adding a Spring Boot example
Let's get rid of shitty Thymeleaf in Spring boot.
Spring guys have already created an issue for that.
I guess that many people would use Rocker but they just don't know how to integrate it.
@ALEXAME - happy to help or take a stab at it when time permits. Just like our ninja framework and jooby integrations, I'm guessing an integration + example is what would be needed.
I am definitely interested. I just compared Thymeleaf, JMustache and Freemarker in Spring Boot, and Rocker performances look promising.
I have actually written a basic rocker integration for spring. Here is the relevant part until I opensource the project.
https://gist.github.com/bendem/8675b7ca856cdab6c208ff6528850f7f
added to the existing converters by extending WebMvcConfigurerAdapter
and overriding
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new RockerMessageConverter());
}
I'm just lurking here but I do like @bendem solution albeit it tightly couples your code with Rocker (via RockerModel). I think a type level Annotation on plain POJO's would be better solution then return RockerModel on every controller method but currently I have no idea if that is possible (I can't come up with a reason why it would not work).
Part of the problem is Spring MVC just assumes the model is a Map<String,?> which isn't ideal for compile time template. FWIW its one of the reasons why we use handlebars.java. That is avoid putting logic in the templates.
I created a Rocker demo with Spring Boot 2 https://github.com/linux-china/rocker-template-demo
check this: rocker-spring-boot-starter https://github.com/iceant/rocker-spring-boot-starter