Update 'minijinja' to 2.0.

This commit is contained in:
Sergio Benitez 2024-05-22 15:03:18 -05:00
parent ca9648c95d
commit 66a2eabc8d
3 changed files with 19 additions and 18 deletions

View File

@ -24,7 +24,11 @@ normpath = "1"
tera = { version = "1.19.0", optional = true }
handlebars = { version = "5.1", optional = true }
minijinja = { version = "1.0.16", optional = true, features = ["loader"] }
[dependencies.minijinja]
version = "2.0.1"
optional = true
features = ["loader", "speedups", "json", "urlencode"]
[dependencies.rocket]
version = "0.5.0"

View File

@ -156,24 +156,21 @@ impl Engines {
/// Returns iterator over template (name, engine_extension).
pub(crate) fn templates(&self) -> impl Iterator<Item = (&str, &'static str)> {
#[cfg(all(feature = "tera", feature = "handlebars"))] {
self.tera.get_template_names()
.map(|name| (name, Tera::EXT))
.chain(self.handlebars.get_templates().keys()
.map(|name| (name.as_str(), Handlebars::EXT)))
}
#[cfg(feature = "tera")]
let tera = self.tera.get_template_names().map(|name| (name, Tera::EXT));
#[cfg(all(feature = "tera", not(feature = "handlebars")))] {
self.tera.get_template_names().map(|name| (name, Tera::EXT))
}
#[cfg(feature = "handlebars")]
let handlebars = self.handlebars.get_templates().keys()
.map(|name| (name.as_str(), Handlebars::EXT));
#[cfg(all(feature = "handlebars", not(feature = "tera")))] {
self.handlebars.get_templates().keys()
.map(|name| (name.as_str(), Handlebars::EXT))
}
#[cfg(feature = "minijinja")]
let minijinja = self.minijinja.templates()
.map(|(name, _)| (name, Environment::EXT));
#[cfg(not(any(feature = "tera", feature = "handlebars")))] {
None.into_iter()
}
#[cfg(not(feature = "tera"))] let tera = std::iter::empty();
#[cfg(not(feature = "handlebars"))] let handlebars = std::iter::empty();
#[cfg(not(feature = "minijinja"))] let minijinja = std::iter::empty();
tera.chain(handlebars).chain(minijinja)
}
}

View File

@ -30,7 +30,7 @@
//! [configurable]: #configuration
//! [Tera]: https://docs.rs/crate/tera/1
//! [Handlebars]: https://docs.rs/crate/handlebars/5
//! [MiniJinja]: https://docs.rs/minijinja/1
//! [MiniJinja]: https://docs.rs/minijinja/2
//!
//! 3. Attach `Template::fairing()` and return a [`Template`] from your routes
//! via [`Template::render()`], supplying the name of the template file