If/Else/ElseIf

The if statement in Twig is comparable with the if statements of PHP. In the simplest form you can use it to test if a variable is defined, not empty or not false:

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

For multiple branches elseif and else can be used like in PHP. You can use more complex expressions there too:

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