a powerful template engine for Rust with minimal dependencies
  • Rust 64.7%
  • Go 30.3%
  • C 2%
  • Python 1.8%
  • HTML 0.5%
  • Other 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Armin Ronacher 29ac0b2936
Some checks failed
Tests / Test on WASI (push) Has been cancelled
Tests / Test on 1.70.0 (push) Has been cancelled
Tests / Test on Latest (No Lock) (push) Has been cancelled
Clippy / build (push) Has been cancelled
Pyright / Pyright (push) Has been cancelled
Rustfmt / build (push) Has been cancelled
Tests / Test on Latest Stable (push) Has been cancelled
Tests / Test C ABI C library (push) Has been cancelled
Tests / Test on nightly (push) Has been cancelled
Tests / Check on 1.70.0 (32bit) (push) Has been cancelled
Tests / Check on 1.70.0 (fuel feature) (push) Has been cancelled
Tests / Test Python binding (default) (push) Has been cancelled
Tests / Test Python binding (freethreaded) (push) Has been cancelled
Tests / Test JS binding (push) Has been cancelled
Tests / Test CLI Linux (push) Has been cancelled
Tests / Test CLI Windows (push) Has been cancelled
feat(templates): add required block support
2026-04-02 11:12:55 +02:00
.cargo loop.nextitem is now a lazy operation (#677) 2025-01-18 14:23:28 +01:00
.devcontainer Add devcontainer.json for Rust (#618) 2024-10-26 21:29:30 +02:00
.github test(cabi): add lightweight C smoke tests and CI coverage 2026-03-15 01:25:18 +01:00
.pi chore(cabi): switch header sync to manual maintenance 2026-03-15 01:16:44 +01:00
.vscode Import captures body (#778) 2025-04-29 12:10:04 +02:00
artwork Added white border to logo and added square logo to crate 2021-12-27 22:06:10 +01:00
benchmarks Performance improvements (#884) 2026-03-15 00:36:02 +01:00
examples chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
fuzz Update dependencies and move MSRV to 1.63 (#635) 2024-11-06 10:32:43 +01:00
minijinja feat(templates): add required block support 2026-04-02 11:12:55 +02:00
minijinja-autoreload chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
minijinja-cabi chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
minijinja-cli chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
minijinja-contrib chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
minijinja-embed chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
minijinja-go feat(templates): add required block support 2026-04-02 11:12:55 +02:00
minijinja-js chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
minijinja-py chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
scripts Minijinja Go Port (#854) 2026-01-13 13:38:30 +01:00
.clippy.toml Typo fixes. (#366) 2023-10-29 21:42:11 +01:00
.gitignore Ensure to tag go releases 2026-01-25 22:30:35 +01:00
_typos.toml Minijinja Go Port (#854) 2026-01-13 13:38:30 +01:00
AGENTS.md Added claude command for changelog 2025-11-30 20:02:26 +01:00
Cargo.lock chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
Cargo.lock.msrv feat: vendor self_cell and make loader default 2026-03-15 14:34:22 +01:00
Cargo.toml Minijinja Go Port (#854) 2026-01-13 13:38:30 +01:00
CHANGELOG.md feat(templates): add required block support 2026-04-02 11:12:55 +02:00
CLAUDE.md Added experimental AI disclosure thing to AGENTS.md 2026-01-24 18:42:20 +01:00
COMPATIBILITY.md Remove line statements from COMPATIBILITY.md (#673) 2025-01-08 10:37:18 +01:00
CONTRIBUTING.md fix small typo (#850) 2025-12-29 22:05:04 +01:00
dist-workspace.toml feat(release): add win arm64 and armv7 cli targets 2026-03-03 12:33:42 +01:00
doc-header.html Added macro support (#123) 2022-09-24 00:24:34 +02:00
HUMAN_VS_MACHINE.md meta: fix bad file reference 2026-03-04 21:23:59 +01:00
LICENSE Initial commit 2021-09-24 00:01:47 +02:00
Makefile test(cabi): add lightweight C smoke tests and CI coverage 2026-03-15 01:25:18 +01:00
README.md chore(release): 2.19.0 2026-04-01 23:27:41 +02:00
UPDATING.md Typos and typos ci (#646) 2024-11-18 19:38:04 +01:00

MiniJinja: a powerful template engine with minimal dependencies

License Crates.io rustc 1.63.0 Documentation

MiniJinja is a powerful but minimal dependency template engine which is based on the syntax and behavior of the Jinja2 template engine for Python.

It's implemented in Rust and Go and is also available via WASM for JavaScript and as a Python extension module and as a command line utility.

It's supports all serde types and only has it as a single required dependency. It supports a range of features from Jinja2 including inheritance, filters and more. The goal is that it should be possible to use some templates in Rust programs without the fear of pulling in complex dependencies for a small problem. Additionally it tries not to re-invent something but stay in line with prior art to leverage an already existing ecosystem of editor integrations.

$ cargo tree
minimal v0.1.0 (examples/minimal)
└── minijinja v2.19.0 (minijinja)
    └── serde v1.0.144

Additionally minijinja is also available as an (optionally pre-compiled) command line executable called minijinja-cli:

$ curl -sSfL https://github.com/mitsuhiko/minijinja/releases/latest/download/minijinja-cli-installer.sh | sh
$ echo "Hello {{ name }}" | minijinja-cli - -Dname=World
Hello World

You can play with MiniJinja online in the browser playground powered by a WASM build of MiniJinja.

Goals:

Example

Example Template:

{% extends "layout.html" %}
{% block body %}
  <p>Hello {{ name }}!</p>
{% endblock %}

Invoking from Rust:

use minijinja::{Environment, context};

fn main() {
    let mut env = Environment::new();
    env.add_template("hello.txt", "Hello {{ name }}!").unwrap();
    let template = env.get_template("hello.txt").unwrap();
    println!("{}", template.render(context! { name => "World" }).unwrap());
}

Getting Help

If you are stuck with MiniJinja, have suggestions or need help, you can use the GitHub Discussions.

Use Cases and Users

Here are some interesting Open Source users and use cases of MiniJinja. The examples link directly to where the engine is used so you can see how it's utilized:

Similar Projects

These are related template engines for Rust:

  • Askama: Jinja inspired, type-safe, requires template precompilation. Has significant divergence from Jinja syntax in parts.
  • Tera: Jinja inspired, dynamic, has divergences from Jinja.
  • Liquid: an implementation of Liquid templates for Rust. Liquid was inspired by Django from which Jinja took its inspiration.
  • TinyTemplate: minimal footprint template engine with syntax that takes lose inspiration from Jinja and handlebars.

Sponsor

If you like the project and find it useful you can become a sponsor.

AI Use Disclaimer

This codebase mostly predates LLM based code generation but some recent features have been built with support of AI. For the AI contribution rules see AI Disclosure Rules.