I begin with python, so I can make mistakes I like the framework Sanic for Python and I need a template engine, and I would prefer to use Jinja2.
I found two extensions for Sanic : 1. https://github.com/yunstanford/jinja2-sanic 2. https://github.com/lixxu/sanic-jinja2
On the Jinja2 documentation, I seen that Jinja can work asynchronous with a specific option "enable_async=True" on the Environnement object et then using "render_async()". So, it's possible to use natively Jinja in async mode.
First question : why use the extensions ? The syntax of Jinja are easy.
Second question : I have check the code of the extensions, and I have not find the reference at the special syntax async in Jinja. I'm not sur but I beleve that the extensions use Jinga in sync mode. If true, why ?
Third question : I checked the Jinja2 code, it seems that template files read normally, and not with a asynchronous method (like aiofiles). So, I don't understand where is the async mode ...
Thanks for your help
Async Support Starting with version 2.9, Jinja2 also supports the Python async and await constructs. As far as template designers go this feature is entirely opaque to them however as a developer you should be aware of how it’s implemented as it influences what type of APIs you can safely expose to the template environment.
Like others have commented you can wrap blocking code in the async await syntax. from jinja2 import Template impoty asyncio