logo
pub struct Handlebars<'reg> { /* private fields */ }
Expand description

The single entry point of your Handlebars templates

It maintains compiled templates and registered helpers.

Implementations

Enable handlebars template source map

Source map provides line/col reporting on error. It uses slightly more memory to maintain the data.

Default is true.

Enable handlebars strict mode

By default, handlebars renders empty string for value that undefined or never exists. Since rust is a static type language, we offer strict mode in handlebars-rust. In strict mode, if you were to render a value that doesn’t exist, a RenderError will be raised.

Return strict mode state, default is false.

By default, handlebars renders empty string for value that undefined or never exists. Since rust is a static type language, we offer strict mode in handlebars-rust. In strict mode, if you were access a value that doesn’t exist, a RenderError will be raised.

Register a Template

This is infallible since the template has already been parsed and insert cannot fail. If there is an existing template with this name it will be overwritten.

Register a template string

Returns TemplateError if there is syntax error on parsing the template.

Register a partial string

A named partial will be added to the registry. It will overwrite template with same name. Currently a registered partial is just identical to a template.

Register a template from a path

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

Remove a template from the registry

Register a helper

Register a decorator

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

Restore the default escape fn.

Get a reference to the current escape fn.

Return true if a template is registered for the given name

Return a registered template,

Return a registered helper

Return a registered decorator

Return all templates registered

Unregister all templates

Render a registered template with some data into a string

  • name is the template name you registered previously
  • data is the data that implements serde::Serialize

Returns rendered string or a struct with error information

Render a registered template with reused context

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

Render a template string using current registry without registering it

Render a template string using reused context data

Render a template string using current registry without registering it

Render a template source using current registry without registering it

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the TypeId of this object.