[英]How to use twig object variable with at-sign @ inside
I send from Symfony object which contains at-sign @
in variable. 我从包含at-sign
@
Symfony对象发送变量。 Object name is invoice and with {{ dump(invoice) }}
in twig template I see object and parameter with path: 对象名称是发票,并且在twig模板中使用
{{ dump(invoice) }}
我看到带有路径的对象和参数:
invoice[0].banSpojDod@showAs
But I dont know how to get value of this banSpojDod@showAs
because there is at-sign @
. 但我不知道如何获得这个
banSpojDod@showAs
价值,因为有@
符号。
Could you help me someone please? 你能帮我一个人吗?
Ok thanks. 好,谢谢。 Problem was that I used it in loop, and some parameters not exists.
问题是我在循环中使用它,并且一些参数不存在。 I needed to add exist conditions.
我需要添加现有条件。 So my final code works:
所以我的最终代码有效:
{% for f in invoice %} {% if attribute(f,'banSpojDod@showAs') is defined %} {{ attribute(f,'banSpojDod@showAs') }} {% endif %} {% endfor %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.