Skip to content
Myr

tests.txt

This file

Path

docs/src/tests.txt

30 lines · 773 bytes

Last changed by

[svn] added block shortcut syntax for jinjaArmin Ronacherbefore adoption4965987

History of this file

Take it

[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9

lines 1–4why, one step back
1==============
2Test Functions3==============4

[svn] Proofread the rest of the docs.Georg Brandlbefore adoption2d53a86

line 5why, one step back
5In addition to filters, Jinja also supports test functions. Test functions

[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9

lines 6–28why, one step back
6always return either ``True`` or ``False``. Inside the template they are available
7using the `is` operator.89Jinja comes with some builtin tests listed in the `designer documentation`_.1011Writing Test Functions12======================1314Test functions look exactly like filters mentioned in the `filter documentation`_:1516.. sourcecode:: python1718 def is_even():19 def wrapped(env, context, value):20 return value % 2 == 021 return wrapped2223Now you have to register that test on an environment:2425.. sourcecode:: python2627 env.tests['even'] = is_even28

[svn] added block shortcut syntax for jinjaArmin Ronacherbefore adoption4965987

line 29why, one step back
29.. _designer documentation: builtins.txt

[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9

line 30why, one step back
30.. _filter documentation: filters.txt