[][src]Struct tower_web::view::Handlebars

pub struct Handlebars { /* fields omitted */ }

Serialize response values using Handlebars templates

This serializer is able to render handlebar templates using structs with #[derive(Response)] and a template name, set with the #[web(template = "<template name>")] annotation.

Methods

impl Handlebars
[src]

Create a new handlebars serializer.

The serializer renders handlebar templates using the response value to populate template variables. The response value must have #[derive(Response)] and a template name specified using the #[web(template = "<template name>")].

Templates are loaded from one of the following locations, checked in order:

  1. A templates directory under the TOWER_WEB_TEMPLATE_DIR environment variable
  2. A templates directory under the crate root (CARGO_MANIFEST_DIR environment variable)
  3. A templates directory under the current working directory.

Templates have the .hbs file extension.

For more control over how templates are loaded, use new_with_registry.

Create a new handlebars serializer.

Similar to new, but uses the provided registry. This allows customizing how templates are rendered.

Trait Implementations

impl Clone for Handlebars
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Handlebars
[src]

Formats the value using the given formatter. Read more

impl Serializer for Handlebars
[src]

A token used by Serializer implementations to identify the specific serialization format to use when encoding a value. Read more

Lookup a serializer and HeaderValue for the given Content-Type string. Read more

Serialize the value using the specified format.

Auto Trait Implementations

impl Send for Handlebars

impl Sync for Handlebars

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

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

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

Important traits for &'a mut R

Immutably borrows from an owned value. Read more

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

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

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

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

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

Important traits for &'a mut R

Mutably borrows from an owned value. Read more

impl<T> Erased for T