Skip to content
Advertisement

Inject html into thymeleaf template

I have thymeleaf templates lying in database,

First I retrieve template and process it:

JavaScript

So now processedTemplate contains html as a String.

Then I retrieve another template and do basically the same, but I want also inject previous template into it, so the java code should look like:

JavaScript

So what should I put into my mainTemplate to be able to inject another html via Context into it?

I saw something like this:

JavaScript

But it works with templates from file, but not when they are lying in database.

Advertisement

Answer

It sounds that you want to insert text without HTML escaping, you do that with th:utext:

JavaScript

Or with inlining:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement