[][src]Struct tinytemplate::TinyTemplate

pub struct TinyTemplate<'template> { /* fields omitted */ }

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]

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]

Register the given formatter function under the given name.

pub fn render<C>(&self, template: &str, context: &C) -> Result<String> where
    C: Serialize
[src]

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]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.