pub struct Handlebars { /* private fields */ }Expand description
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.
Implementations§
Source§impl Handlebars
impl Handlebars
Sourcepub fn new() -> Handlebars
pub fn new() -> Handlebars
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:
- A
templatesdirectory under theTOWER_WEB_TEMPLATE_DIRenvironment variable - A
templatesdirectory under the crate root (CARGO_MANIFEST_DIRenvironment variable) - A
templatesdirectory under the current working directory.
Templates have the .hbs file extension.
For more control over how templates are loaded, use
new_with_registry.
Sourcepub fn new_with_registry(registry: Registry) -> Handlebars
pub fn new_with_registry(registry: Registry) -> Handlebars
Create a new handlebars serializer.
Similar to new, but uses the provided registry. This allows
customizing how templates are rendered.
Trait Implementations§
Source§impl Clone for Handlebars
impl Clone for Handlebars
Source§fn clone(&self) -> Handlebars
fn clone(&self) -> Handlebars
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Handlebars
impl Debug for Handlebars
Source§impl Serializer for Handlebars
impl Serializer for Handlebars
Auto Trait Implementations§
impl !Freeze for Handlebars
impl !RefUnwindSafe for Handlebars
impl Send for Handlebars
impl Sync for Handlebars
impl Unpin for Handlebars
impl !UnwindSafe for Handlebars
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more