pub struct TinyTemplate { /* private fields */ }
Expand description
The TinyTemplate struct is the entry point for the TinyTemplate library. It contains the template and formatter registries and provides functions to render templates as well as to register templates and formatters.
Implementations§
Source§impl TinyTemplate
impl TinyTemplate
Sourcepub fn new() -> TinyTemplate
pub fn new() -> TinyTemplate
Create a new TinyTemplate registry. The returned registry contains no templates, and has
format_unescaped
registered as a formatter named “unescaped”.
Sourcepub fn add_template(&mut self, name: String, text: String) -> Result<()>
pub fn add_template(&mut self, name: String, text: String) -> Result<()>
Parse and compile the given template, then register it under the given name.
Sourcepub fn set_default_formatter<F>(&mut self, formatter: F)
pub fn set_default_formatter<F>(&mut self, formatter: F)
Changes the default formatter from format
to formatter
. Usefull in combination with format_unescaped
to deactivate HTML-escaping
Sourcepub fn add_formatter<F>(&mut self, name: String, formatter: F)
pub fn add_formatter<F>(&mut self, name: String, formatter: F)
Register the given formatter function under the given name.
Trait Implementations§
Source§impl Default for TinyTemplate
impl Default for TinyTemplate
Source§fn default() -> TinyTemplate
fn default() -> TinyTemplate
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TinyTemplate
impl !RefUnwindSafe for TinyTemplate
impl Send for TinyTemplate
impl Sync for TinyTemplate
impl Unpin for TinyTemplate
impl !UnwindSafe for TinyTemplate
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