ThymeLeaf is a templating engine.
http://www.thymeleaf.org/documentation.html
Possible integration points
In CDI, even standalone:
- IContext - the map of values available for the template. Those could be filled from CDI.
@Inject CDIThymeContext ctx;
The interface IContext has only getVariables(), so the values are not resolved per case - whole map needs to be given at the time of this call.
- Also, we could make the template names type-safe, by introducing one qualifier per page.
// Inject object with the template "Home", the template engine, and CDIThymeContext.
@Inject @Template @Home ThymeTemplate tpl;
// Additional variable
tpl.getContext().setVariable("foo", bar);
// Process
tpl.process( response.getWriter() );
Additionally, in Application Server:
- IResourceResolver - to load resources from deployments. ThymeLeaf's ClassLoaderResourceResolver uses just
ClassLoaderUtils.getClassLoader(ClassLoaderResourceResolver.class).getResourceAsStream(resourceName);
- @Resource TemplateEngine templateEngine; - inject template engine configured as module. (Probably not much useful, ThymeLeaf is pretty simple, almost no config.)