pub struct Engine { /* private fields */ }Expand description
Loads templates from a directory and renders them.
One engine is built at boot and shared; render takes &self so handlers
can render concurrently.
Implementations§
Source§impl Engine
impl Engine
pub fn new(root: impl Into<PathBuf>) -> Self
Sourcepub fn with_reload(self, reload: bool) -> Self
pub fn with_reload(self, reload: bool) -> Self
Re-read every template from disk on every render.
This is the whole reason the engine interprets an AST instead of generating Rust: with reload on, a designer edits a template, hits refresh, and sees the change — no recompile, no restart. Leave it off in production, where the parse should happen once.
pub fn root(&self) -> &Path
pub fn reloads(&self) -> bool
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Forget every parsed template.
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