-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to write Jinja loaders that use async/await #1304
Comments
I'd be fine adding it in, but I have no idea what the API/implementation would look like. Did you have something in mind? |
My ideal implementation as a user would be the one listed above - where the jinja/src/jinja2/asyncsupport.py Lines 169 to 172 in 1eca37b
The implementation looks tricky though, since I imagine getting It may be more Jinja-like to have a new |
I'm using Tortoise ORM all over the place and being able to asynchronously load templates from a DB is something I'd definitely use 🙂 |
I am using a custom loader from database in a Django async application... Is there a way to make the loader async? Otherwise I can't load templates from database.. :( |
I'm writing code within an async framework, using Jinja's excellent async mode.
I want to write a custom template loader that can load templates asynchronously from my database - but as far as I can tell the Jinja loader mechanisms only work with synchronous functions.
Borrowing an example from here I'd love to be able to do something like this:
I initially implemented a workaround for this by loading templates asynchronously in my own code and compiling them for Jinja with
jinja_env.from_string(plugin_template_source)
- but then I realized that this doesn't work for templates loaded internally by Jinja due to{% extends ... %}
and{% include ... %}
blocks.I'd be happy to help implement this if it's a feature that Jinja maintainers agree should be part of the library.
The text was updated successfully, but these errors were encountered: