具有变量作为参数的Assetic get_image

时间:2013-07-04 13:21:41

标签: php image symfony twig assetic

任何人都可以告诉我为什么这样:

{% for key, logo in it %}
{% set imageUrl = "bundles/acme/img/it/"~logo %}
<li><img src="{{ get_image(imageUrl) }}" alt="{{ key }}"0/></li>
{% endfor %}

导致这个:

An exception has been thrown during the compilation of a template ("Attribute "value" does not exist for Node "Twig_Node_Expression_Name".")

任何建议都是

1 个答案:

答案 0 :(得分:1)

使用asset()方法代替......

{% for key, logo in it %}
   {% set imageUrl = "bundles/acme/img/it/"~logo %}
   <li><img src="{{ asset(imageUrl) }}" alt="{{ key }}"/></li>
{% endfor %}