summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorremidebette <remi.debette@gmail.com>2021-03-02 23:12:30 +0100
committerDavid Lord <davidism@gmail.com>2021-04-05 11:36:54 -0700
commit3642ae7fef491222fb81fa3c0ae01bffca25fa41 (patch)
tree4caa3755de45b32415443dff118000eeab74a169 /src
parent06c7c6fee10b33162446dc87dd1d8cadb1d006d0 (diff)
downloadjinja2-3642ae7fef491222fb81fa3c0ae01bffca25fa41.tar.gz
NativeEnvironment supports async mode
Diffstat (limited to 'src')
-rw-r--r--src/jinja2/nativetypes.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/jinja2/nativetypes.py b/src/jinja2/nativetypes.py
index 3ac70cf..8867a31 100644
--- a/src/jinja2/nativetypes.py
+++ b/src/jinja2/nativetypes.py
@@ -93,5 +93,19 @@ class NativeTemplate(Template):
except Exception:
return self.environment.handle_exception()
+ async def render_async(self, *args, **kwargs):
+ if not self.environment.is_async:
+ raise RuntimeError(
+ "The environment was not created with async mode enabled."
+ )
+
+ vars = dict(*args, **kwargs)
+ ctx = self.new_context(vars)
+
+ try:
+ return native_concat([n async for n in self.root_render_func(ctx)])
+ except Exception:
+ return self.environment.handle_exception()
+
NativeEnvironment.template_class = NativeTemplate