Is it possible to create a dynamic replace in Thymeleaf?
I have the following controller:
@Controller
public class LoginController {
@RequestMapping
In Thymeleaf 3.0, the following solution has worked for me:
(Note however, that I use it with fixed name of the fragment and dynamic name of the template, so the parantheses around :: (${template})
might be optional.)
The solution is inspired by documentation for Thymeleaf in https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#fragment-specification-syntax
Both templatename and selector in the above examples can be fully-featured expressions (even conditionals!) like:
Note again how the surrounding ~{...} envelope is optional in th:insert/th:replace