Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2

License

NotificationsYou must be signed in to change notification settings

mitsuhiko/minijinja

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniJinja: a powerful template engine for Rust with minimal dependencies

LicenseCrates.iorustc 1.63.0Documentation

MiniJinja is a powerful but minimal dependency template engine for Rust whichis based on the syntax and behavior of theJinja2 template engine for Python.

It's implemented on top ofserde and only has it as a single requireddependency. It supportsa range of features from Jinja2including inheritance, filters and more. The goal is that it should be possibleto use some templates in Rust programs without the fear of pulling in complexdependencies for a small problem. Additionally it tries not to re-inventsomething but stay in line with prior art to leverage an already existingecosystem of editor integrations.

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

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

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

You can play with MiniJinja onlinein the browser playgroundpowered by a WASM build of MiniJinja.

Goals:

Example

Example Template:

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

Invoking from Rust:

use minijinja::{Environment, context};fnmain(){letmut 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());}

Use Cases and Users

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

Getting Help

If you are stuck withMiniJinja, have suggestions or need help, you can use theGitHub Discussions.

Related Crates

Similar Projects

These are related template engines for Rust:

  • Askama: Jinja inspired, type-safe, requires templateprecompilation. Has significant divergence from Jinja syntax in parts.
  • Rinja: Jinja inspired, type-safe, requires templateprecompilation. Has significant divergence from Jinja syntax in parts.
  • Tera: Jinja inspired, dynamic, has divergences from Jinja.
  • TinyTemplate: minimal footprint template enginewith syntax that takes lose inspiration from Jinja and handlebars.
  • 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 canbecome asponsor.

License and Links

About

MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp