Macro minijinja_embed::embed_templates
source · macro_rules! embed_templates { ($path:expr, $exts:expr, $bundle_name:expr) => { ... }; ($path:expr) => { ... }; ($path:expr, $exts:expr) => { ... }; }
Expand description
Utility macro to store templates in a build.rs file.
This needs to be invoked in build.rs file with at least
the path to the templates. Optionally it can be filtered
by extension and an alternative bundle name can be provided.
These are all equivalent:
minijinja_embed::embed_templates!("src/templates");
minijinja_embed::embed_templates!("src/templates", &[][..]);
minijinja_embed::embed_templates!("src/templates", &[][..], "main");To embed diffent folders, alternative bundle names can be provided. Also tempaltes can be filtered down by extension to avoid accidentally including unexpected templates.
minijinja_embed::embed_templates!("src/templates", &[".html", ".txt"]);Later they can then be loaded into a Jinja environment with
the load_templates! macro.
§Panics
This function panics if the templates are not valid (eg: invalid syntax). It’s not possible to handle this error by design. During development you should be using dynamic template loading instead.