MiniJinja
MiniJinja is a powerful but minimal dependency template engine for Rust which is based on the syntax and behavior of the Jinja2 template engine for Python.
It's implemented on top of serde
and only has a single dependency. It supports
a range of features from Jinja2 including inheritance, filters and more.
Example
use minijinja::Environment;
use serde::Serialize;
#[derive(Serialize)]
pub struct Context {
name: String,
}
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".into()
}).unwrap());
}
License and Links
- Documentation
- Issue Tracker
- License: Apache-2.0