[][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> !Send for TinyTemplate<'template>

impl<'template> !Sync for TinyTemplate<'template>

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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