Expression test

IsContainingAll

Returns true if a list contains all values in another list.

Input:
(value = “list”, type=“list”, required = true)
Params:
_(value = “listtwo”, type=“list”, desc = “The second list to check if every element is in the first list”, required = true)

{{ [1, 2, 3] is containingall [2, 3] }}

IsContaining

Returns true if a list contains a value.

Input:
(value = “list”, type = “list”, required = true)
Params:
(value = “value”, type = “object”, desc = “The value to check is in the list”, required = true)

{{ [1, 2, 3] is containing 2 }}

IsDefined

Returns true if the variable is defined.

Input:
(value = “value”, type = “object”, required = true)

{% if variable is defined %}
    <!--code to render if variable is defined-->
{% endif %}

IsDivisibleBy

Returns true if a variable is divisible by a number.

Input:
(value = “num”, type = “number”, required = true)
Params:
(value = “divisor”, type = “number”, desc = “The number to check whether a number is divisible by”, required = true)

{% if variable is divisbleby 5 %}
    <!--code to render if variable can be divided by 5-->
{% else %}
    <!--code to render if variable cannot be divided by 5-->
{% endif %}

IsEqualTo

Returns true if an object has the same value as another object.

Input:
(value = “first”, type = “object”, required = true)
Params:
(value = “other”, type = “object”, desc = “Another object to check equality against”, required = true)

{% if variable is equalto 42 %}
    the foo attribute evaluates to the constant 42
{% endif %}

Usage with the selectattr filter:

{{ users|selectattr("email", "equalto", "foo@bar.invalid") }}

IsEven

Returns true if the value is even.

Input:
(value = “num”, type = “number”, required = true)

{% if variable is even %}
    <!--code to render if variable is an even number-->
{% else %}
    <!--code to render if variable is an odd number-->
{% endif %}

IsIterable

Returns true if the object is iterable (sequence, dict, etc.).

Input:
(value = “object”, type = “object”, required = true)

{% if variable is iterable %}
    <!--code to render if items in a variable can be iterated through-->
{% endif %}

IsLower

Returns true if the given string is all lowercase.

Input:
(value = “string”, type = “string”, required = true)

{% if variable is lower %}
    <!--code to render if variable value is lowercased-->
{% endif %}

IsMapping

Returns true if the given object is a dict.

Input:
(value = “object”, type = “object”, required = true)

{% if variable is mapping %}
    <!--code to render when object is a dict-->
{% endif %}

IsNone

Returns true if the given object is null/none.

Input:
(value = “object”, type = “object”, required = true)

{% unless variable is none %}
    <!--code to render unless the variable is null-->
{% endunless %}

IsNumber

Returns true if the object is a number.

Input:
(value = “object”, type = “object”, required = true)

{% if variable is number %}
    {{ variable * 1000000 }}
{% else %}
    The variable is not a number.
{% endif %}

IsOdd

Returns true if a number is an odd number.

Input:
(value = “num”, type = “number”, required = true)

{% if variable is odd %}
    <!--code to render if variable is an odd number-->
{% else %}
    <!--code to render if variable is an even number-->
{% endif %}

IsSameAs

Returns true if a variable is pointing at same object as another variable.

Input:
(value = “object”, type = “object”, required = true)
Params:
(value = “other”, type = “object”, desc = “A second object to check the variables value against”, required = true)

{% if var_one is sameas var_two %}
    <!--code to render if variables have the same value as one another-->
{% endif %}

IsSequence

Returns true if the variable is a sequence. Sequences are variables that are iterable.

Input:
(value = “object”, type = “object”, required = true)

{% if variable is sequence %}
    <!--code to render if items in a variable is a sequence-->
{% endif %}

IsStringContaining

Returns true if an object is a string which contains a specified other string.

Input:
(value = “string”, type = “string”, required = true)
Params:
(value = “check”, type = “string”, desc = “A second string to check is contained in the first string”, required = true)

{% if variable is string_containing 'foo' %}
    !--code to render if variable contains 'foo' -->
{% endif %}

IsString

Returns true if an object is a string.

Input:
(value = “value”, type = “object”, required = true)

{% if variable is string %}
    <!--code to render if a variable contains a string value-->
{% endif %}

IsStringStartingWith

Returns true if an object is a string which starts with a specified other string.

Input:
(value = “value”, type = “string”, required = true)
Params:
(value = “check”, type = “string”, desc = “A second string to check is the start of the first string”, required = true)

{% if variable is string_startingwith 'foo' %}
    <!--code to render if variable starts with 'foo'-->
{% endif %}

IsTruthy

Returns true if an object is ‘truthy’.

Input:
(value = “value”, type = “object”, required = true)

{% if variable is truthy %}
    <!--code to render a  boolean variable is True-->
{% endif %}

IsUndefined

Returns true if an object is undefined.

Input:
(value = “value”, type = “object”, required = true)

{% if variable is undefined %}
    <!--code to render if variable is undefined-->
{% endif %}

IsUpper

Returns true if string is all uppercase.

Input:
(value = “value”, type = “string”, required = true)

{% if variable is upper %}
    <!-- code to render if variable value is uppercased -->
{% endif %}

IsWithin

Returns true if a value is within a list.

Input:
(value = “value”, type = “object”, required = true)
Params:
(value = “list”, type = “list”, desc = “A list to check if the value is in.”, required = true)

{{ 2 is within [1, 2, 3] }}
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.