Twig-在带有2个条件的if语句中发布

时间:2019-06-19 11:56:48

标签: html twig

在一个非常简单的算法问题面前,我很头疼。

我希望我的定位标记每次 EXCEPT 都显示一次:

当两个条件都为真时-> app.user.username == item.email AND'delete'== action.name

到目前为止,我已经做到了:

{% if app.user.username == item.email and 'delete' == action.name  %}
           <a href="">...</a>
{% endif %}

在上面的代码中,我做相反的事情……

这就是我需要的: enter image description here

什么是我需要的正确组合?

1 个答案:

答案 0 :(得分:1)

您应该简单地negate发布条件,例如:

{% if not (app.user.username == item.email and 'delete' == action.name)  %}

您可以在this working fiddle

中进行测试

希望获得帮助