Skip to content

zidsa/jinja2-async

Repository files navigation

jinja2-async

jinja2-async is a small wrapper around Jinja2 that provides async-aware loaders and an async-first environment API.

Install

python -m pip install jinja2-async

Basic usage

import asyncio

from jinja2_async import AsyncEnvironment, FileSystemLoader


async def main() -> None:
    env = AsyncEnvironment(loader=FileSystemLoader("templates"))

    # AsyncEnvironment intentionally aliases `get_template` to an async method,
    # so it returns an awaitable.
    tmpl = await env.get_template("hello.html")
    rendered = await tmpl.render_async(name="World")
    print(rendered)


asyncio.run(main())

Documentation

The docs are plain Markdown under docs/:

  • docs/index.md
  • docs/quickstart.md
  • docs/api.md

Changelog

See CHANGELOG.md.

About

Jinja2, but with async template loaders

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages