Skip to main content

No project description provided

Project description

starlette-async-jinja

Code style: crackerjack

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

  • Only asynchronous template loaders (not yet tested but should work) are currently supported

  • The Jinja bytecodecache requires an asynchronous Redis backend

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starlette_async_jinja-1.8.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

starlette_async_jinja-1.8.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file starlette_async_jinja-1.8.0.tar.gz.

File metadata

  • Download URL: starlette_async_jinja-1.8.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.20.0.post1 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for starlette_async_jinja-1.8.0.tar.gz
Algorithm Hash digest
SHA256 01e2a8093e74b136ccaebc54940f4ccfd5ac83ddfcaf2ab4acdbf66a6eb5f1ea
MD5 b357b35584d0e51799aae9dcf11d55cd
BLAKE2b-256 ea52199a104e8a535db3a1bff84f8e37f50fe078cd5ad2f54c2f8531b516f8d3

See more details on using hashes here.

File details

Details for the file starlette_async_jinja-1.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for starlette_async_jinja-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6b9e6bbcc320fcad7b448396e0ce6c29a347c00bfd7fbb70955298b3725204b
MD5 d82b2d5522a2a98c5edcdb02e370dd3a
BLAKE2b-256 2553fdb78c488728e3ca181474baa57b37f3a6343918562b8a31d9043a7f1eb8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page