Struct handlebars::Handlebars [] [src]

pub struct Handlebars {
    // some fields omitted
}

The single entry point of your Handlebars templates

It maintains compiled templates and registered helpers.

Methods

impl Registry
[src]

fn new() -> Registry

fn register_template(&mut self, name: &str, template: Template)

Register a template

fn register_template_string(&mut self, name: &str, tpl_str: String) -> Result<()TemplateError>

Register a template string

fn register_template_file(&mut self, name: &str, tpl_path: &Path) -> Result<()TemplateFileError>

Register a template from a path

fn register_template_source(&mut self, name: &str, tpl_source: &mut Read) -> Result<()TemplateFileError>

Register a template from std::io::Read source

fn unregister_template(&mut self, name: &str)

remove a template from the registry

fn register_helper(&mut self, name: &str, def: Box<HelperDef + 'static>) -> Option<Box<HelperDef + 'static>>

register a helper

fn register_escape_fn<F: 'static + Fn(&str) -> String + Send + Sync>(&mut self, escape_fn: F)

Register a new escape fn to be used from now on by this registry.

fn unregister_escape_fn(&mut self)

Restore the default escape fn.

fn get_escape_fn(&self) -> &Fn(&str) -> String

Get a reference to the current escape fn.

fn get_template(&self, name: &str) -> Option<&Template>

Return a registered template,

fn get_helper(&self, name: &str) -> Option<&Box<HelperDef + 'static>>

Return a registered helper

fn get_templates(&self) -> &HashMap<StringTemplate>

Return all templates registered

fn clear_templates(&mut self)

Unregister all templates

fn render<T>(&self, name: &str, ctx: &T) -> Result<StringRenderError> where T: ToJson

Render a registered template with some data into a string

fn renderw(&self, name: &str, context: &Context, writer: &mut Write) -> Result<()RenderError>

Render a registered template with some data to the std::io::Write

fn template_render<T>(&self, template_string: &str, ctx: &T) -> Result<StringTemplateRenderError> where T: ToJson

render a template string using current registry without register it

fn template_renderw(&self, template_string: &str, context: &Context, writer: &mut Write) -> Result<()TemplateRenderError>

render a template string using current registry without register it

fn template_renderw2(&self, template_source: &mut Read, context: &Context, writer: &mut Write) -> Result<()TemplateRenderError>

render a template source using current registry without register it