rocker icon indicating copy to clipboard operation
rocker copied to clipboard

Consider adding a Spring Boot example

Open ALEXAME opened this issue 7 years ago • 6 comments

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 avatar Jun 15 '17 00:06 ALEXAME

@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.

jjlauer avatar Jun 15 '17 13:06 jjlauer

I am definitely interested. I just compared Thymeleaf, JMustache and Freemarker in Spring Boot, and Rocker performances look promising.

mwatel42 avatar Nov 23 '17 16:11 mwatel42

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());
}

bendem avatar Nov 23 '17 20:11 bendem

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.

agentgt avatar Jan 10 '18 19:01 agentgt

I created a Rocker demo with Spring Boot 2 https://github.com/linux-china/rocker-template-demo

linux-china avatar May 19 '18 07:05 linux-china

check this: rocker-spring-boot-starter https://github.com/iceant/rocker-spring-boot-starter

iceant avatar Jun 12 '19 10:06 iceant