使用百里香,我正在尝试生成以下结构:
<li class="active">
<a href="/bootstrap/dashboard">Dashboard</a>
</li>
<li>
<a href="#">Charts<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li><a href="/bootstrap/flot">Flot Charts</a></li>
</ul>
</li>
我将其修改如下:
<li th:each="menu : ${sideForm.menu}" th:class="${activeItem} == ${menu.item} ? 'active' : null">
<a href="#" th:if="${#lists.isEmpty(menu.submenu)}" th:href="@{'/' + ${sideForm.parentMenu} + '/' + ${menu.item}}" th:text="#{${menu.title}}">Item</a>
<a href="#" th:unless="${#lists.isEmpty(menu.submenu)}" th:text="#{${menu.title}}">Item<span class="fa arrow" th:class="fa arrow"></span></a>
<ul class="nav nav-second-level" th:unless="${#lists.isEmpty(menu.submenu)}" th:class="'nav nav-second-level'">
<li th:each="submenu : ${menu.submenu}">
<a href="#" th:unless="${#lists.isEmpty(menu.submenu)}" th:href="@{'/' + ${sideForm.parentMenu} + '/' + ${submenu.item}}" th:text="#{${submenu.title}}">Sub Item</a>
</li>
</ul>
</li>
呈现如下:
<li class="active">
<a href="/bootstrap/dashboard">dashboard</a>
</li>
<li>
<a href="#">Charts</a>
<ul class="nav nav-second-level">
<li><a href="/bootstrap/flot">Flot Charts</a></li>
</ul>
</li>
我添加了"<span class="fa arrow" th:class="fa arrow"></span>"
,为什么不在真正的HTML中呈现?我该如何解决?
答案 0 :(得分:1)
来自Expected Output:
Name : XYZ
telephone:(305) 535-1379
streetAddress:1755 Alton Rd
addressLocality:Miami Beach
addressRegion:FL
postalCode:33139
latitude:25.792588
longitude:-80.141214
Estimated delivery time:45-60 min
标记的th:text
会导致百里香用替换其内容的给定值,并替换<a>
标记
span
你应该将标题包装在另一个html标签中,例如<a href="#" th:unless="${#lists.isEmpty(menu.submenu)}" th:text="#{${menu.title}}">
<!-- everything in the <a> tag will be deleted by the th:text -->
Item
<span class="fa arrow" th:class="fa arrow"></span>
</a>
或span
(th:块在处理后不会被渲染)
th:block
或者,使用内联文字:
<a href="#" th:unless="${#lists.isEmpty(menu.submenu)}">
<th:block th:text="#{${menu.title}}">Item</th:block>
<span class="fa arrow" th:class="fa arrow"></span>
</a>