MiniJinja Python Bindings

2.19.0 · active · verified Thu Apr 16

MiniJinja is an experimental Python binding of the Rust MiniJinja template engine, currently at version 2.19.0. It provides a powerful, minimal dependency template engine with a high degree of compatibility with Jinja2. MiniJinja is noted for its strong sandboxing capabilities and its better positioning for future free-threaded Python adoption, though Jinja2 may perform faster on current Python 3.14 single-threaded environments. The library sees active development with frequent releases.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a MiniJinja environment, load a template from a string, and render it with a provided context using the `context!` macro for convenience.

from minijinja import Environment, context

# Create a Jinja environment
env = Environment()

# Add a template (can also load from files using a Loader)
env.add_template("hello.html", "Hello {{ name }}! Today is {{ day }}.").unwrap()

# Get the template and render it with context
tmpl = env.get_template("hello.html").unwrap()
rendered_output = tmpl.render(context!(name => "World", day => "Thursday")).unwrap()

print(rendered_output)

view raw JSON →