MiniJinja: a powerful template engine for Rust with minimal dependencies
[![Build Status](https://github.com/mitsuhiko/minijinja/workflows/Tests/badge.svg?branch=main)](https://github.com/mitsuhiko/minijinja/actions?query=workflow%3ATests) [![License](https://img.shields.io/github/license/mitsuhiko/minijinja)](https://github.com/mitsuhiko/minijinja/blob/main/LICENSE) [![Crates.io](https://img.shields.io/crates/d/minijinja.svg)](https://crates.io/crates/minijinja) [![rustc 1.61.0](https://img.shields.io/badge/rust-1.61%2B-orange.svg)](https://img.shields.io/badge/rust-1.61%2B-orange.svg) [![Documentation](https://docs.rs/minijinja/badge.svg)](https://docs.rs/minijinja)Hello {{ name }}!
{% endblock %} ``` ## API ```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](https://github.com/mitsuhiko/minijinja/discussions). ## Related Crates * [minijinja-autoreload](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-autoreload): provides auto reloading functionality of environments * [minijinja-embed](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-embed): provides utilities for embedding templates in a binary * [minijinja-contrib](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-contrib): provides additional utilities too specific for the core * [minijinja-py](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-py): makes MiniJinja available to Python * [minijinja-cli](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cli): a command line utility. ## Similar Projects These are related template engines for Rust: * [Askama](https://crates.io/crates/askama): Jinja inspired, type-safe, requires template precompilation. Has significant divergence from Jinja syntax in parts. * [Tera](https://crates.io/crates/tera): Jinja inspired, dynamic, has divergences from Jinja. * [TinyTemplate](https://crates.io/crates/tinytemplate): minimal footprint template engine with syntax that takes lose inspiration from Jinja and handlebars. * [Liquid](https://crates.io/crates/liquid): an implementation of Liquid templates for Rust. Liquid was inspired by Django from which Jinja took it's inspiration. ## Sponsor If you like the project and find it useful you can [become a sponsor](https://github.com/sponsors/mitsuhiko). ## License and Links - [Documentation](https://docs.rs/minijinja/) - [Discussions](https://github.com/mitsuhiko/minijinja/discussions) - [Examples](https://github.com/mitsuhiko/minijinja/tree/main/examples) - [Issue Tracker](https://github.com/mitsuhiko/minijinja/issues) - [MiniJinja Playground](https://mitsuhiko.github.io/minijinja-playground/) - License: [Apache-2.0](https://github.com/mitsuhiko/minijinja/blob/main/LICENSE)