You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not exactly a bug, but more precisely a limitation of all versions of Thymeleaf until 2.1. This should not happen in 3.0 (currently in BETA02).
The problem is in the way Thymeleaf <= 2.1 performs fragment insertion: it basically gets the tree of nodes corresponding to the fragment being inserted and hangs that tree onto the DOM of the higher-level template being processed. By the time these nodes are processed, they have no clue about the original template they came from, so this only resolves to the first-level template (the one for which the template engine was originally called).
Again, though, this has changed in 3.0. The new architecture allows markup events to know about the template they come from, and this references inside a fragment should work as you are expecting them to work.
Section "8.1 Including template fragments - Defining and referencing fragments" of the docs states that:
But it seems that only works fine making full reference
th:include="test-fragment :: contentB"
.I've made a small test project to reproduce the issue, it can be found here: https://github.com/t-cst/thymeleaf-springboot-test
test.html
test-fragment.html
Output is:
Case 2 and 3 are missing.
Thymeleaf - User Forum › General Usage › Include a fragment from the same thymeleaf template using "this :: content" or ":: content" not working as expected
The text was updated successfully, but these errors were encountered: