Twig 是否支持三元(if-else 简写)运算符?
我需要一些条件逻辑,例如:
{%if ability.id in company_abilities %}
<tr class="selected">
{%else%}
<tr>
{%endif%}
但在 Twig 中使用简写。
最佳答案
{{ (ability.id in company_abilities) ? 'selected' : '' }}
三元运算符记录在 ' other operators 下'
关于php - Twig 三元运算符,简写 if-then-else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11820297/