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

Popular posts from this blog

node.js - StackOverflow API not returning JSON -

ios - Apple Push Notifications + TestFlight + Enterprise wildcard provisioning profile -

android - Drag and drop in ScrollView -