首页 > 解决方案 > Twig - 如果数组中的数组值之一

问题描述

我尝试做这样的事情,有人知道如何处理吗?

这是我目前拥有的:

{{ ('1' in app.request.pathInfo or '2' in app.request.pathInfo or '3' in app.request.pathInfo) ? 'active' : '' }} X

这就是我要的 :

{{ (['1','2','3'] in app.request.pathInfo) ? 'active' : '' }} V

标签: twig

解决方案


逆逻辑有效;)

{{ app.request.pathInfo in ['frame_brand', 'frame_elevation', 'frame_model'] ? 'active' }}

推荐阅读