Dynamic part of text value

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic part of text value

marfij
Hi all,
 I would like to ask if it's possible to have a variable inside of the "text", which will
 be interpreted as a value?

 Example:

 Java code:
final Context ctx = new Context();
ctx.setVariable("surname", "Doe");
ctx.setVariable("name", "Jan ${surname}");
return this.templateEngine.process("test-template", ctx);

Then in Thymeleaf:
<p th:text="${name}"/>

And I would like it to be displayed like: "Jan Doe".

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic part of text value

marfij
Just in case someone has the same issue in the future:
use the two-step processing. First with ClassloaderResolver, second with StringTemplateResolver where the result of first processing will be passed.

Regards