pub struct Engine { /* private fields */ }Expand description
The template engine.
Wraps a MiniJinja Environment and provides:
- Filesystem-based template loading from the directory in
TemplateConfig::templates_path. - Automatic registration of minijinja-contrib filters and functions.
- A
t()function (available in every template) that looks up thelocalecontext variable and delegates to the built-in translation store. - A
static_url()function that appends a content-hash query parameter to asset paths for cache-busting. - In debug builds, the template cache is cleared on every render so changes on disk are picked up without a restart (hot-reload).
Engine is cheaply cloneable — it wraps an Arc internally.
Use Engine::builder to obtain an EngineBuilder.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn builder() -> EngineBuilder
pub fn builder() -> EngineBuilder
Returns a new EngineBuilder with default settings.
Sourcepub fn static_service(&self) -> Router
pub fn static_service(&self) -> Router
Returns an axum::Router that serves static files from
TemplateConfig::static_path under the TemplateConfig::static_url_prefix
URL prefix.
In debug builds the router adds Cache-Control: no-cache. In release builds it
adds Cache-Control: public, max-age=31536000, immutable.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more