replace error

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

replace error

John
Hi,

I have an error using th:replace.

<html>
<body>
   <div th:fragment="LABEL">fragment_label</div>
   <form ....>
      <label>_label tag1</label><input ../>
      <label>_label tag2</label><input ../>
      <div th:replace="~${:: LABEL}"></div><input ../>
   </form>
</body>
</html>

Result:

<html>
<body>
   <form>
      <label>_label tag1</label><input ../>
      <label>_label tag2</label><input ../>
      <label>fragment_label_label tag1_label tag2</label>
   </form>
</body>
</html>

Thymeleaf had fragment and label tags!
If I change LABEL for LABELS works!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: replace error

danielfernandez
Administrator
This is a naming conflict.

Your ~{::LABEL} fragment expression does not only match th:fragment="LABEL", but also all the <label> tags in your markup. If you need to specify you are trying to match a fragment name and not any tags with the same name, you should use "~{::%LABEL}".

Regards,
Daniel.
Loading...