From: David Lord Date: Mon, 22 Jul 2019 16:45:20 +0000 (-0700) Subject: Merge branch 'master' into 557-map-default X-Git-Tag: 2.11.0~76^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F985%2Fhead;p=thirdparty%2Fjinja.git Merge branch 'master' into 557-map-default --- 81783615eafe70e506119e8dfbf26477f538d743 diff --cc CHANGES.rst index 5c55276a,2b6b7632..9a116531 --- a/CHANGES.rst +++ b/CHANGES.rst @@@ -13,11 -13,25 +13,25 @@@ unrelease :class:`~environment.Environment` enables it, in order to avoid a slow initial import. (`#765`_) - Python 2.6 and 3.3 are not supported anymore. - - The `map` filter in async mode now automatically awaits - - Added `default` parameter for the `map` filter. (`#985`_) - + - The ``map`` filter in async mode now automatically awaits + - Added a new ``ChainableUndefined`` class to support getitem + and getattr on an undefined object. (`#977`_) + - Allow ``{%+`` syntax (with NOP behavior) when + ``lstrip_blocks == False`` (`#748`_) -- Added ``default`` param for ``map`` filter. (`#557`_) ++- Added a ``default`` parameter for the ``map`` filter. (`#557`_) + + .. _#557: https://github.com/pallets/jinja/issues/557 .. _#765: https://github.com/pallets/jinja/issues/765 - .. _#985: https://github.com/pallets/jinja/pull/985 + .. _#748: https://github.com/pallets/jinja/issues/748 + .. _#977: https://github.com/pallets/jinja/issues/977 + + + Version 2.10.2 + -------------- + + _Unreleased_ + + - Fix Python 3.7 deprecation warnings. Version 2.10.1 diff --cc jinja2/filters.py index 94751b87,da3e535c..2b45b3cc --- a/jinja2/filters.py +++ b/jinja2/filters.py @@@ -76,9 -71,8 +71,8 @@@ def make_attrgetter(environment, attrib for part in attribute: item = environment.getitem(item, part) - if isinstance(item, Undefined) and default: + if default and isinstance(item, Undefined): item = default - break if postprocess is not None: item = postprocess(item) @@@ -970,7 -1012,7 +1012,7 @@@ def do_map(*args, **kwargs) .. sourcecode:: jinja - {{ users|map(attribute='username', default='Anonymous')|join(', ') }} - Users on this page: {{ users|map(attribute="username", default="Anonymous")|join(", ") }} ++ {{ users|map(attribute="username", default="Anonymous")|join(", ") }} Alternatively you can let it invoke a filter by passing the name of the filter and the arguments afterwards. A good example would be applying a