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.
Sourcepub fn with_translator(self, translator: Arc<dyn Translate>) -> Self
pub fn with_translator(self, translator: Arc<dyn Translate>) -> Self
Give @lang somewhere to look.
Without one the directive renders the key it was given, which is the
same thing a missing translation does — a page saying auth.sign_in is
a page somebody fixes.
Sourcepub fn routes_cell(&self) -> Arc<OnceLock<Arc<dyn Routes>>> ⓘ
pub fn routes_cell(&self) -> Arc<OnceLock<Arc<dyn Routes>>> ⓘ
The cell the finished router is put into. App fills this; nothing
else should.
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 !UnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin 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