[−][src]Struct tower_web::view::Handlebars
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]
impl Handlebarspub fn new() -> Handlebars[src]
pub fn new() -> HandlebarsCreate 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.
pub fn new_with_registry(registry: Registry) -> Handlebars[src]
pub fn new_with_registry(registry: Registry) -> HandlebarsCreate 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]
impl Clone for Handlebarsfn clone(&self) -> Handlebars[src]
fn clone(&self) -> HandlebarsReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Handlebars[src]
impl Debug for Handlebarsfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Serializer for Handlebars[src]
impl Serializer for Handlebarstype Format = ()
A token used by Serializer implementations to identify the specific serialization format to use when encoding a value. Read more
fn lookup(&self, name: &str) -> Option<ContentType<Self::Format>>[src]
fn lookup(&self, name: &str) -> Option<ContentType<Self::Format>>Lookup a serializer and HeaderValue for the given Content-Type string. Read more
fn serialize<T>(
&self,
value: &T,
_: &Self::Format,
context: &SerializerContext
) -> Result<Bytes, Error> where
T: Serialize, [src]
fn serialize<T>(
&self,
value: &T,
_: &Self::Format,
context: &SerializerContext
) -> Result<Bytes, Error> where
T: Serialize, Serialize the value using the specified format.
Auto Trait Implementations
impl Send for Handlebars
impl Send for Handlebarsimpl Sync for Handlebars
impl Sync for HandlebarsBlanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 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]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, ⓘImportant traits for &'a mut Rfn borrow(&self) -> &T[src]
fn borrow(&self) -> &TImmutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 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]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, ⓘImportant traits for &'a mut Rfn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T> Erased for T
impl<T> Erased for T