【发布时间】:2016-02-20 03:39:37
【问题描述】:
好像参数没有正确传递...
{% set items = {
item: {
'id': '1',
'brand': 'client1',
'description': 'solutions.client1.description' | trans},
item: {
'id': '2',
'brand': 'client2',
'description': 'solutions.client2.description' | trans}
} %}
{% include 'site/case-excerpt.html.twig'
with {'id': items.item.id,
'brand': items.item.brand,
'description': items.item.description
}
%}
然后在site/case-excerpt.html.twig 文件中:
{% include 'site/testimonials/item.html.twig'
with {'id': id,
'brand': brand,
'description': description
}
%}
在site/testimonials/item.html.twig 文件中:
<div class="carousel-item {{ id }}">
<img src="images/brands/{{ brand }}.jpg">
<p>
{{ description }}
</p>
</div>
预期的输出如下:
<div class="carousel-item 1">
<img src="images/brands/client1.jpg">
<p>
I'm the content of the translation for the first client
</p>
</div>
<div class="carousel-item 2">
<img src="images/brands/client2.jpg">
<p>
I'm the content of the translation for the second client
</p>
</div>
我放弃了通过items 手动循环的想法,因为它似乎可以很好地完成,here for example。
【问题讨论】:
标签: php twig twig-extension