pub struct TemplateEngine { /* private fields */ }Expand description
A template engine over a directory of templates.
A view name is dotted and maps to a path: posts.show →
<root>/posts/show.view.html.
Implementations§
Source§impl TemplateEngine
impl TemplateEngine
Sourcepub fn without_cache(self) -> Self
pub fn without_cache(self) -> Self
Re-read and re-parse templates on every render.
Sourcepub fn with_extension(self, extension: impl Into<String>) -> Self
pub fn with_extension(self, extension: impl Into<String>) -> Self
Use a different file extension.
Sourcepub fn path_for(&self, name: &str) -> PathBuf
pub fn path_for(&self, name: &str) -> PathBuf
The file a view name maps to.
Every segment is sanitised and the result is always inside the
template root. That matters because a view name can reach the engine
from a template (@include('…')) and, in a careless application, from
user input. Naively replacing dots with separators is not enough: a
name like ..secrets produces a leading separator, and Path::join
with a rooted path discards the base — silently reading from the
filesystem root.
Trait Implementations§
Source§impl Debug for TemplateEngine
impl Debug for TemplateEngine
Auto Trait Implementations§
impl !Freeze for TemplateEngine
impl RefUnwindSafe for TemplateEngine
impl Send for TemplateEngine
impl Sync for TemplateEngine
impl Unpin for TemplateEngine
impl UnsafeUnpin for TemplateEngine
impl UnwindSafe for TemplateEngine
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