Skip to content
Myr

Clarified and extended the docs for the `{select|reject}[attr]` filters. (#231)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jochen Kupperschmidt · committed by David Lord · parent 760ce60 · Browse files · 1 file+20 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−8 removed

  • other:+20 added−8 removed

1 file+20 added−8 removed

modified:jinja2/filters.py+20 added-8 removed
844 unmodified lines
845846847@contextfilter848def do_select(*args, **kwargs):849 """Filters a sequence of objects by applying a test to the object and only850 selecting the ones with the test succeeding.849 """Filters a sequence of objects by applying a test to each object,850 and only selecting the objects with the test succeeding.851852 If no test is specified, each object will be evaluated as a boolean.853854 Example usage:855856 .. sourcecode:: jinja857
6 unmodified lines
864865866@contextfilter867def do_reject(*args, **kwargs):866 """Filters a sequence of objects by applying a test to the object and867 rejecting the ones with the test succeeding.868 """Filters a sequence of objects by applying a test to each object,869 and rejecting the objects with the test succeeding.870871 If no test is specified, each object will be evaluated as a boolean.872873 Example usage:874875 .. sourcecode:: jinja876
5 unmodified lines
882883884@contextfilter885def do_selectattr(*args, **kwargs):882 """Filters a sequence of objects by applying a test to an attribute of an883 object and only selecting the ones with the test succeeding.886 """Filters a sequence of objects by applying a test to the specified887 attribute of each object, and only selecting the objects with the888 test succeeding.889890 If no test is specified, the attribute's value will be evaluated as891 a boolean.892893 Example usage:894895 .. sourcecode:: jinja896
6 unmodified lines
903904905@contextfilter906def do_rejectattr(*args, **kwargs):899 """Filters a sequence of objects by applying a test to an attribute of an900 object or the attribute and rejecting the ones with the test succeeding.907 """Filters a sequence of objects by applying a test to the specified908 attribute of each object, and rejecting the objects with the test909 succeeding.910911 If no test is specified, the attribute's value will be evaluated as912 a boolean.913914 .. sourcecode:: jinja915916 {{ users|rejectattr("is_active") }}917 {{ users|rejectattr("email", "none") }}
85 unmodified lines