我想在Thymeleaf的 th:replace 函数中添加一些HTML,如下所示:
<div th:replace="elements/listview :: row (subtext='Test<br />Test')" ></div>
我的'listview'模板是这样的:
<div class="listview-row" th:fragment="row">
<span class="listview-subtext" th:if="${subtext != null}" th:utext="${subtext}">
</span>
</div>
它无法编译。当然我希望它编译为:
<div class="listview-row">
<span class="listview-subtext">
Test<br />Test
</span>
</div>
..随着HTML的到位。有没有办法做到这一点?提前感谢您的帮助。
答案 0 :(得分:0)
试试这个:
<div class="listview-row" th:fragment="row(subtext)">
<span class="listview-subtext" th:if="${subtext != null}" th:utext="${subtext}">
</span>
</div>
&#13;
并像这样使用它:
<div th:replace="elements/listview :: row ('Test<br />Test')" ></div>
&#13;