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 fileTake it
[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9
lines 1–4why, one step back1==============2Test Functions3==============4[svn] Proofread the rest of the docs.Georg Brandlbefore adoption2d53a86
line 5why, one step back5In 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 back6always return either ``True`` or ``False``. Inside the template they are available7using 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 back29.. _designer documentation: builtins.txt[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9
line 30why, one step back30.. _filter documentation: filters.txt