==========
Conditions
==========

The ``{% if %}`` tag evaluates a variable, and if that variable is "true" (i.e.
exists, is not empty, and is not a false boolean value) the contents of the
block are output::

    {% if user_list %}
      Number of users in the list: {{ user_list|count }}
    {% else %}
      No users found.
    {% endif %}

In the above, if ``athlete_list`` is not empty, the number of athletes will be
displayed by the ``{{ athlete_list|length }}`` variable.

As you can see, the ``if`` tag can take an option ``{% else %}`` clause that
will be displayed if the test fails.

You can also inverse the check using ``not``::

    {% if not user_list %}
      No users found
    {% endif %}

If you use just ``if`` and ``if not`` you can also apply filters on those
values::

    {% if user.name|strip %}
        username given
    {% endif %}



Comparison
==========

You can also check if two variables (or a variable and a string for
example) match::

    {% if item.id equals "index" %} class="active"{% endif %}

Or if they don't match::

    {% if not page equals active_page %}
        ...
    {% endif %}

In both cases you can't apply filters.
