In my application I need to use "hardwired" html templates which I will bake in by adding them to resources/templates
and "dynamic" text templates that I want to store in String
s at runtime.
My code looks similar to this:
@Autowired
SpringTemplateEngine templateEngine;
templateEngine.addTemplateResolver(new DynamicTemplateResolver());
Context context = new Context();
context.setVariable("foo1", ... );
templateEngine.process("eitherStaticOrDynamic", context, output);
The problem lies within DynamicTemplateResolver
which implements ITemplateResolver
. I tried to use the examples given at Process string templates with thymeleaf 3, but they seem to no longer work on current versions of Spring.
How can I resolve a template from String
s ? I use Spring Boot 2.2