Meliborn Meliborn - 23 days ago 7
Twig Question

Ternary operators in Twig php

Is it possible to use ternary operators in twig template? Now, for adding some class to DOM element depend on some condition I do like this:

{%if in company_abilities%}
<tr class="selected">

Instead of

<tr class="<?=in_array($ability->id, $company_abilities) ? 'selected' : ''?>">

in native php template engine.

{{ ( in company_abilities) ? 'selected' : '' }}

The ternary operator is documented under 'other operators'