Update 'minijinja' to 2.0.

This commit is contained in:
Sergio Benitez 2024-05-22 15:03:18 -05:00
parent 347d9da663
commit 9e3f9ae00f
3 changed files with 19 additions and 18 deletions

View File

@ -27,7 +27,11 @@ normpath = "1"
tera = { version = "1.19.0", optional = true } tera = { version = "1.19.0", optional = true }
handlebars = { version = "5.1", 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] [dependencies.rocket]
version = "0.6.0-dev" version = "0.6.0-dev"

View File

@ -156,24 +156,21 @@ impl Engines {
/// Returns iterator over template (name, engine_extension). /// Returns iterator over template (name, engine_extension).
pub(crate) fn templates(&self) -> impl Iterator<Item = (&str, &'static str)> { pub(crate) fn templates(&self) -> impl Iterator<Item = (&str, &'static str)> {
#[cfg(all(feature = "tera", feature = "handlebars"))] { #[cfg(feature = "tera")]
self.tera.get_template_names() let tera = self.tera.get_template_names().map(|name| (name, Tera::EXT));
.map(|name| (name, Tera::EXT))
.chain(self.handlebars.get_templates().keys()
.map(|name| (name.as_str(), Handlebars::EXT)))
}
#[cfg(all(feature = "tera", not(feature = "handlebars")))] { #[cfg(feature = "handlebars")]
self.tera.get_template_names().map(|name| (name, Tera::EXT)) let handlebars = self.handlebars.get_templates().keys()
} .map(|name| (name.as_str(), Handlebars::EXT));
#[cfg(all(feature = "handlebars", not(feature = "tera")))] { #[cfg(feature = "minijinja")]
self.handlebars.get_templates().keys() let minijinja = self.minijinja.templates()
.map(|name| (name.as_str(), Handlebars::EXT)) .map(|(name, _)| (name, Environment::EXT));
}
#[cfg(not(any(feature = "tera", feature = "handlebars")))] { #[cfg(not(feature = "tera"))] let tera = std::iter::empty();
None.into_iter() #[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 //! [configurable]: #configuration
//! [Tera]: https://docs.rs/crate/tera/1 //! [Tera]: https://docs.rs/crate/tera/1
//! [Handlebars]: https://docs.rs/crate/handlebars/5 //! [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 //! 3. Attach `Template::fairing()` and return a [`Template`] from your routes
//! via [`Template::render()`], supplying the name of the template file //! via [`Template::render()`], supplying the name of the template file