Open tschuehly opened 5 months ago
A couple of issues with me helping at the moment:
What I mean by the last one is that w/ JStachio you don't do
@RequestMapping("/home"
public String home() {
return "views/home.mustache";
}
But rather:
@RequestMapping("/home")
@ResponseBody
public Home home() {
return new Home(); // JStache model.
}
Alternatively one can return a View
with
Thus a custom JStachioModelView might be needed. I'm fairly sure this part will not be a problem but worth mentioning.
Thanks for your comment, @agentgt!
Spring ViewComponent is not bound in any way to Kotlin and is natively usable in Java. For Kotlin compatibility the user can use JStachio with kapt.
The only thing that is needed is to configure JStachio to process the ViewComponent templates and then resolve them based on the expected output path.
There is a MethodReturnValueHandler that puts the template path as view and the ViewContext record into the ModelAndViewContainer. The template is automatically put into the IViewContext by a AOP Aspect.
Then nesting needs to be handled. In JTE it's pretty easy as the JTE ViewContext just implements the Content Interface that is natively renderable in JTE expressions: ViewContext
It would be good to add another template language to Spring ViewComponent. JStachio seems to be the best solution for Mustache https://github.com/jstachio/jstachio
Maybe @agentgt can help with that!