module documentation

Built-in template tests used with the ``is`` operator.

Function test_boolean Return true if the object is a boolean value.
Function test_defined Return true if the variable is defined:
Function test_divisibleby Check if a variable is divisible by a number.
Function test_escaped Check if the value is escaped.
Function test_even Return true if the variable is even.
Function test_false Return true if the object is False.
Function test_filter Check if a filter exists by name. Useful if a filter may be optionally available.
Function test_float Return true if the object is a float.
Function test_in Check if value is in seq.
Function test_integer Return true if the object is an integer.
Function test_iterable Check if it's possible to iterate over an object.
Function test_lower Return true if the variable is lowercased.
Function test_mapping Return true if the object is a mapping (dict etc.).
Function test_none Return true if the variable is none.
Function test_number Return true if the variable is a number.
Function test_odd Return true if the variable is odd.
Function test_sameas Check if an object points to the same memory address than another object:
Function test_sequence Return true if the variable is a sequence. Sequences are variables that are iterable.
Function test_string Return true if the object is a string.
Function test_test Check if a test exists by name. Useful if a test may be optionally available.
Function test_true Return true if the object is True.
Function test_undefined Like :func:`defined` but the other way round.
Function test_upper Return true if the variable is uppercased.
Constant TESTS Undocumented
def test_boolean(value): (source)

Return true if the object is a boolean value. .. versionadded:: 2.11

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_defined(value): (source)

Return true if the variable is defined: .. sourcecode:: jinja {% if variable is defined %} value of variable: {{ variable }} {% else %} variable is not defined {% endif %} See the :func:`default` filter for a simple way to set undefined variables.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_divisibleby(value, num): (source)

Check if a variable is divisible by a number.

Parameters
value:intUndocumented
num:intUndocumented
Returns
boolUndocumented
def test_escaped(value): (source)

Check if the value is escaped.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_even(value): (source)

Return true if the variable is even.

Parameters
value:intUndocumented
Returns
boolUndocumented
def test_false(value): (source)

Return true if the object is False. .. versionadded:: 2.11

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
@pass_environment
def test_filter(env, value): (source)

Check if a filter exists by name. Useful if a filter may be optionally available. .. code-block:: jinja {% if 'markdown' is filter %} {{ value | markdown }} {% else %} {{ value }} {% endif %} .. versionadded:: 3.0

Parameters
env:EnvironmentUndocumented
value:strUndocumented
Returns
boolUndocumented
def test_float(value): (source)

Return true if the object is a float. .. versionadded:: 2.11

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_in(value, seq): (source)

Check if value is in seq. .. versionadded:: 2.10

Parameters
value:t.AnyUndocumented
seq:t.ContainerUndocumented
Returns
boolUndocumented
def test_integer(value): (source)

Return true if the object is an integer. .. versionadded:: 2.11

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_iterable(value): (source)

Check if it's possible to iterate over an object.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_lower(value): (source)

Return true if the variable is lowercased.

Parameters
value:strUndocumented
Returns
boolUndocumented
def test_mapping(value): (source)

Return true if the object is a mapping (dict etc.). .. versionadded:: 2.6

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_none(value): (source)

Return true if the variable is none.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_number(value): (source)

Return true if the variable is a number.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_odd(value): (source)

Return true if the variable is odd.

Parameters
value:intUndocumented
Returns
boolUndocumented
def test_sameas(value, other): (source)

Check if an object points to the same memory address than another object: .. sourcecode:: jinja {% if foo.attribute is sameas false %} the foo attribute really is the `False` singleton {% endif %}

Parameters
value:t.AnyUndocumented
other:t.AnyUndocumented
Returns
boolUndocumented
def test_sequence(value): (source)

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

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_string(value): (source)

Return true if the object is a string.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
@pass_environment
def test_test(env, value): (source)

Check if a test exists by name. Useful if a test may be optionally available. .. code-block:: jinja {% if 'loud' is test %} {% if value is loud %} {{ value|upper }} {% else %} {{ value|lower }} {% endif %} {% else %} {{ value }} {% endif %} .. versionadded:: 3.0

Parameters
env:EnvironmentUndocumented
value:strUndocumented
Returns
boolUndocumented
def test_true(value): (source)

Return true if the object is True. .. versionadded:: 2.11

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_undefined(value): (source)

Like :func:`defined` but the other way round.

Parameters
value:t.AnyUndocumented
Returns
boolUndocumented
def test_upper(value): (source)

Return true if the variable is uppercased.

Parameters
value:strUndocumented
Returns
boolUndocumented
TESTS = (source)

Undocumented

Value
{'odd': test_odd,
 'even': test_even,
 'divisibleby': test_divisibleby,
 'defined': test_defined,
 'undefined': test_undefined,
 'filter': test_filter,
 'test': test_test,
...