[−][src]Struct tinytemplate::TinyTemplate
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.
Methods
impl<'template> TinyTemplate<'template>
[src]
pub fn new() -> TinyTemplate<'template>
[src]
Create a new TinyTemplate registry. The returned registry contains no templates, and has
format_unescaped
registered as a formatter named "unescaped".
pub fn add_template(
&mut self,
name: &'template str,
text: &'template str
) -> Result<()>
[src]
&mut self,
name: &'template str,
text: &'template str
) -> Result<()>
Parse and compile the given template, then register it under the given name.
pub fn add_formatter<F>(&mut self, name: &'template str, formatter: F) where
F: 'static + Fn(&Value, &mut String) -> Result<()>,
[src]
F: 'static + Fn(&Value, &mut String) -> Result<()>,
Register the given formatter function under the given name.
pub fn render<C>(&self, template: &str, context: &C) -> Result<String> where
C: Serialize,
[src]
C: Serialize,
Render the template with the given name using the given context object. The context
object must implement serde::Serialize
as it will be converted to serde_json::Value
.
Trait Implementations
impl<'template> Default for TinyTemplate<'template>
[src]
fn default() -> TinyTemplate<'template>
[src]
Auto Trait Implementations
impl<'template> !Send for TinyTemplate<'template>
impl<'template> !Sync for TinyTemplate<'template>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,