divisible by

The divisible by test checks to see if the variable value is evenly divisible by a number.

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

Note that there is a space between "divisible" and "by" and "by" has a parameter. 

The parameter for the test should be a number.

You can also use a variable for the number parameter.

{% set test = 10 %}
{% set number = 3 %}
{% if test is divisible by(number) %}
    <p>{{ test }} is divisible by {{ number }}</p>
{% elseif %}
    <p>{{ test }} is NOT divisible by {{ number }}</p>
{% endif %}

In the above example the test would fail because 10 is not evenly divisible by 3. However, if number was 5 then the test would pass because 10 is evenly divisible by 5.

< Back to the list of tests