Skip to content

dldevinc/aioja

Repository files navigation

aioja

Async version of Jinja2.

PyPI Build Status

This library contains a wrappers for the standard Jinja2 library. In addition to Jinja's built-in enable_async, the following has been added:

Notice: Keep in mind that the enable_async option is forced to True in order to compile templates correctly. In particular, this means that you should use Template.render_async method instead of Template.render.

Install

pip install aioja

Quick Start

from aioja.environment import Environment
from aioja.loaders import FileSystemLoader
from aioja.bccache.aiocache import AioCacheBytecodeCache


env = Environment(
    loader=FileSystemLoader('templates'),
    # ...
    # bytecode_cache=AioCacheBytecodeCache()
    # ...
)

template = await env.get_template('index.html')
content = await template.render_async({
    'page_id': 123
})