小编Ayk*_*vik的帖子

使用Twig变量作为其他Twig变量的属性名称

我必须使用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 %}
Run Code Online (Sandbox Code Playgroud)

谢谢.

php symfony twig

19
推荐指数
2
解决办法
1万
查看次数

标签 统计

php ×1

symfony ×1

twig ×1