From: Jochen Kupperschmidt Date: Mon, 30 May 2016 14:48:11 +0000 (+0200) Subject: Clarified and extended the docs for the `{select|reject}[attr]` filters. (#231) X-Git-Tag: 2.9~27^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a49e066af3d88d1edb34aa1680b668c959dfcf7;p=thirdparty%2Fjinja.git Clarified and extended the docs for the `{select|reject}[attr]` filters. (#231) --- diff --git a/jinja2/filters.py b/jinja2/filters.py index 9b553a23..a4504069 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -846,8 +846,10 @@ def do_map(*args, **kwargs): @contextfilter def do_select(*args, **kwargs): - """Filters a sequence of objects by applying a test to the object and only - selecting the ones with the test succeeding. + """Filters a sequence of objects by applying a test to each object, + and only selecting the objects with the test succeeding. + + If no test is specified, each object will be evaluated as a boolean. Example usage: @@ -863,8 +865,10 @@ def do_select(*args, **kwargs): @contextfilter def do_reject(*args, **kwargs): - """Filters a sequence of objects by applying a test to the object and - rejecting the ones with the test succeeding. + """Filters a sequence of objects by applying a test to each object, + and rejecting the objects with the test succeeding. + + If no test is specified, each object will be evaluated as a boolean. Example usage: @@ -879,8 +883,12 @@ def do_reject(*args, **kwargs): @contextfilter def do_selectattr(*args, **kwargs): - """Filters a sequence of objects by applying a test to an attribute of an - object and only selecting the ones with the test succeeding. + """Filters a sequence of objects by applying a test to the specified + attribute of each object, and only selecting the objects with the + test succeeding. + + If no test is specified, the attribute's value will be evaluated as + a boolean. Example usage: @@ -896,8 +904,12 @@ def do_selectattr(*args, **kwargs): @contextfilter def do_rejectattr(*args, **kwargs): - """Filters a sequence of objects by applying a test to an attribute of an - object or the attribute and rejecting the ones with the test succeeding. + """Filters a sequence of objects by applying a test to the specified + attribute of each object, and rejecting the objects with the test + succeeding. + + If no test is specified, the attribute's value will be evaluated as + a boolean. .. sourcecode:: jinja