symfony - Many conditions if true in twig -
i have many attributes boolean type , if true show yes else show no. shall condition "if" each attribute or there other short method ?
you can use ternary operator achieve shorter if
-syntax in twig.
example:
# i'm creating example array here {% set user = { 'active' : true } %} # now, instead of ... user {% if user.active %}active{% else %}inactive{% endif %}. # ... can write: user {{ user.active ? 'active' : 'inactive' }}.
output:
user active.
Comments
Post a Comment