【发布时间】:2013-01-07 09:05:00
【问题描述】:
我必须使用 Twig 变量作为另一个 Twig 变量的属性。
在 for 循环中,我获取特定实体的属性,并希望使用这些属性在另一个 for 循环中获取实体变量的属性内容。
一些代码来说明这一点:
{% for entity in entities %}
{{entity.foo}}, {{entity.bar}}<br />
{% for property in specialdynamicproperties %}
{{entity.property}} <!-- property has the content foobar for example, I want to use it as the property accessor for entity -->
{% endfor %}
{% endfor %}
谢谢。
【问题讨论】:
-
你试过attribute function吗?
-
@mbosecke:这对我有用,只需将其写为答案,以便我接受,谢谢 :)