Crate minijinja_embed
source ·Expand description
This crate adds utilities to embed MiniJinja templates
directly in the binary. It is a static version of the
path_loader
function with some optional filtering.
First you need to add this as regular and build dependency:
cargo add minijinja-embed
cargo add minijinja-embed --build
Afterwards you can embed a template folder in your build.rs
script. You can also do this conditional based on a feature
flag. In this example we just embed all templates in the
src/templates
folder:
fn main() {
// ...
minijinja_embed::embed_templates!("src/templates");
}
Later when you create the environment you can load the embedded templates:
ⓘ
use minijinja::Environment;
let mut env = Environment::new();
minijinja_embed::load_templates!(&mut env);
For more information see embed_templates
.
Macros§
- Utility macro to store templates in a
build.rs
file. - Loads embedded templates into the environment.