Skip to content
Myr

Merge pull request #806 from methane/lazy-async-patch

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

Lazy asyncsupport.patch_all()

authored by David Lord · committed by GitHub · parents c0c3b78, 989a7db · Browse files · 5 files+15 added−15 removed
This commit

State

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

Diff stats

5 files+15 added−15 removed

  • other:+15 added−15 removed

5 files+15 added−15 removed

modified:docs/templates.rst+2 added-4 removed
1307 unmodified lines
1308The general syntax is ``<do something> if <something is true> else <do1309something else>``.13101311The `else` part is optional. If not provided, the else block implicitly1312evaluates into an undefined object:1312evaluates into an undefined object::13131314.. sourcecode:: jinja1314 {{ ('[%s]' % page.title) if page.title }}13151316 {{ '[%s]' % page.title if page.title }}131613181317.. _builtin-filters:13181319List of Builtin Filters1320-----------------------
347 unmodified lines
modified:jinja2/__init__.py-11 removed
68 unmodified lines
69 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',70 'evalcontextfilter', 'evalcontextfunction', 'make_logging_undefined',71 'select_autoescape',72]737475def _patch_async():76 from jinja2.utils import have_async_gen77 if have_async_gen:78 from jinja2.asyncsupport import patch_all79 patch_all()808182_patch_async()83del _patch_async
modified:jinja2/asyncsupport.py+3 added
252 unmodified lines
253 except StopAsyncIteration:254 after = _last_iteration255 return AsyncLoopContext(async_iterator, undefined, after, length, recurse,256 depth0)257258259patch_all()
modified:jinja2/environment.py+2 added
332 unmodified lines
333 self.extensions = load_extensions(self, extensions)334335 self.enable_async = enable_async336 self.is_async = self.enable_async and have_async_gen337 if self.is_async:338 import jinja2.asyncsupport # runs patch_all() once339340 _environment_sanity_check(self)341342 def add_extension(self, extension):
936 unmodified lines
modified:CHANGES.rst+8 added
1.. currentmodule:: jinja223Jinja Changelog4===============56
1 unmodified line
8------------910unreleased1112- Async support is only loaded the first time an13 :class:`~environment.Environment` enables it, in order to avoid a14 slow initial import. (`#765`_)1516.. _#765: https://github.com/pallets/jinja/issues/765171819Version 2.1020------------2122released on November 8th 2017
588 unmodified lines