Twig Tests

defined

Checks to see if a variable is defined in the current context.

{% if foo is defined %}
   ...
{% endif %}

View details

divisible by

Checks to see if the variable value is evenly divisible by a number.

{% if variable is divisible by(3) %}
    ...
{% endif %}

View details

empty

Tests to see if the value is an empty string, an empty array, an empty hash, exactly false, or exactly null.

{% if var is empty %}
   ...
{% endif %}

View details

even

Tests to see if the value of the variable is a number and is even.

{% if var is even %}
   ...
{% endif %}

View details

float

Checks to see if the value is a float.

This test is unique to Aptuitiv. It is not part of the core Twig functionality.
{% if var is float %}
{% endif %}

View details

integer

Checks to see if the value is an integer.

This test is unique to Aptuitiv. It is not part of the core Twig functionality.
{% if var is integer %}
{% endif %}

View details

iterable

Tests a variable to see if it is an array or a traversable object. Note that it doesn't test if the array or object has any values.

{% if posts is iterable %}
   <p>posts is an array and may have some values to loop through.</p>
{% endif %}

View details

null

Tests to see if the value of the variable is exactly null.

{% if variable is null %}
   <p>the value of the variable is NULL</p>
{% endif %}

View details

numeric

Checks to see if the value is a number.

This test is unique to Aptuitiv. It is not part of the core Twig functionality.
{% if var is numeric %}
{% endif %}

View details

odd

Tests to see if the value of the variable is a number and is odd.

{% if number is odd %}
   ...
{% endif %}

View details

same as

Tests to see if the value of the variable is exactly the same as another variable or value. It's the equivalent of an "===" test.

{% if variable is same as(false) %}
    <p>the value of the variable is false</p>
{% endif %}

View details

string

Checks to see if the value is a string.

This test is unique to Aptuitiv. It is not part of the core Twig functionality.
{% if var is string %}
{% endif %}

View details

This documentation is only for Aptuitiv CMS. Learn more.
Get Started With Aptuitiv