【发布时间】:2016-11-28 12:26:37
【问题描述】:
我有一个带有 {{ item }} 循环的暴露过滤器。它呈现以下actual render
<a href="something.php" class="container label"> Something </a>
我想这样渲染
<a href="something.php">
<div class="container">
<div class="label"> Something </div>
</div>
</a>
这是我的 twiig 模板代码
{% for child in children %}
{%
set itemclasses = [
'project-label',
'project-term' ~ loop.index,
]
%}
{% set item = attribute(element, child) %}
{% set item = item|merge ({'#attributes': { 'class': itemclasses }}) %}
<li>
{{ item }}
</li>
{% endfor %}
请帮帮我, 谢谢
【问题讨论】:
-
为什么for循环使用
<li>标签而不是<div>标签。不清楚你真正想做什么? -
<li> </li>用于项目循环 --- 但我想要真正打破{{item}}循环渲染。