tests.txt
This file
Path
docs/src/tests.txt
30 lines · 776 bytes
Last changed by
[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9
History of this fileTake it
[svn] doc update, setup.py update, added turbogears pluginArmin Ronacherbefore adoption8ebf1f9
lines 1–30why, one step back1==============2Test Functions3==============45Additionally to filters Jinja also supports test functions. Test functions6always 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_even2829.. _designer documentation: designerdoc.txt30.. _filter documentation: filters.txt