starlette-async-jinja

Jinja2 is_async template support for Starlette +
About
- Provides AsyncJinja2Templates class which enables use of the is_async Jinja environment flag with
Startlette and Starlette based applications like FastAPI
- Integrated Jinja Partials
and Jinja Fragments
- Supports asynchronous template loaders (examples here)
Issues
Usage
Import AsyncJinja2Templates:
from starlette_async_jinja import AsyncJinja2Templates
Replace Jinja2Templates with AsyncJinja2Templates:
templates = AsyncJinja2Templates(directory='templates')
Render the async template in the response:
async def homepage(request: Request):
return await templates.TemplateResponse(request, 'index.html')
or:
async def homepage(request: Request):
return await templates.render_template(request, 'index.html')
Acknowledgements
License
BSD-3-Clause