Twig Basic

Concatenate two string in Twig

{% set c = a ~ b %}
{{ 'http://' ~ app.request.host }}

Not condition in twig

{% if not user.subscribed %}
    <p>You are not subscribed to our mailing list.</p>
{% endif %}

For multiple conditions, and and or can be used:

{% if temperature > 18 and temperature < 27 %}
      It's a nice day for a walk in the park.
{% endif %}

For multiple branches, elseif and else can be used like in PHP.

{% if kenny.sick %}
     Kenny is sick.
{% elseif kenny.dead %}
     You killed Kenny! You bastard!!!
{% else %}
     Kenny looks okay --- so far
{% endif %}

You can also test if an array is not empty:

{% if users %}
    <ul>
        {% for user in users %}
            <li>{{ user.username|e }}</li>
        {% endfor %}
    </ul>
{% endif %}