The goal of this project is to provide a simple way to evaluate Thymeleaf templates with FEEL expressions.
The templates expressions are evaluated with FEEL so you can use expressions like ${now()+duration("P3M")}. For a good overview of available expressions, you can refer to Camunda's FEEL expression introduction
This can be changed by modifying the ThymeleafConfig encoding, prefix, expression language, date formatting patterns, etc.
The default behavior is to read templates from the "template" resource folder. They should be suffixed by ".html". You can override this behaviour by providing a customTemplateResolver. You can use this mechanism to load templates from a database or from a file system.
ThymeleafConfig config = new ThymeleafConfig();
config.setDatePattern("dd/MM/yyyy");
config.setPrefix("/somewhere/");
config.setSuffix(".xhtml");
config.setFeelExpressions(true);
config.setCustomTemplateResolver(new ICustomTemplateResolver() {
@Override
public String getTemplateContent(String templateName) {
return "Test <span th:text='${username}'></span></h4>";
}
});
Context context = new Context();
[...]
TemplateEngineFactory.getTemplateEngine("engineName", config).process("templateName", context)
You can use as many TemplateEngine as you need with different configs. If you don't give the engine a name, you will get the default one.
You can import it to your maven or gradle project as a dependency
<dependency>
<groupId>io.camunda</groupId>
<artifactId>thymeleaf-feel</artifactId>
<version>1.1.1</version>
</dependency>
Issues and PRs are welcome.