pub struct TinyTemplate<'template> { /* 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<'template> TinyTemplate<'template>
impl<'template> TinyTemplate<'template>
Sourcepub fn new() -> TinyTemplate<'template>
pub fn new() -> TinyTemplate<'template>
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: &'template str,
text: &'template str,
) -> Result<()>
pub fn add_template( &mut self, name: &'template str, text: &'template str, ) -> Result<()>
Parse and compile the given template, then register it under the given name.
Sourcepub fn set_default_formatter<F>(&mut self, formatter: &'template F)
pub fn set_default_formatter<F>(&mut self, formatter: &'template 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: &'template str, formatter: F)
pub fn add_formatter<F>(&mut self, name: &'template str, formatter: F)
Register the given formatter function under the given name.
Trait Implementations§
Source§impl<'template> Default for TinyTemplate<'template>
impl<'template> Default for TinyTemplate<'template>
Source§fn default() -> TinyTemplate<'template>
fn default() -> TinyTemplate<'template>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'template> Freeze for TinyTemplate<'template>
impl<'template> !RefUnwindSafe for TinyTemplate<'template>
impl<'template> !Send for TinyTemplate<'template>
impl<'template> !Sync for TinyTemplate<'template>
impl<'template> Unpin for TinyTemplate<'template>
impl<'template> !UnwindSafe for TinyTemplate<'template>
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