Trait TidyTemplateExt

Source
pub trait TidyTemplateExt: Template {
    // Required methods
    fn as_tidy(&self) -> TidyTemplate<&Self>;
    fn into_tidy(self) -> TidyTemplate<Self>
       where Self: Sized;
}
Available on crate feature askama only.
Expand description

Extension trait to wrap a Template in TidyTemplate.

use askama::Template;
use html5ever_arena_dom::TidyTemplateExt;

#[derive(Debug, Template)]
#[template(
    ext = "html",
    source = "<title>Test</title><h1>Hello, <b>{{user}}</strong>!</h2"
)]
struct Hello<'a> {
    user: &'a str,
}

assert_eq!(
    Hello { user: "wörld" }.as_tidy().render().unwrap(),
    "<html><head><title>Test</title></head>\
     <body><h1>Hello, <b>wörld!</b></h1></body></html>"
);

Required Methods§

Source

fn as_tidy(&self) -> TidyTemplate<&Self>

Wrap a reference to the template.

Source

fn into_tidy(self) -> TidyTemplate<Self>
where Self: Sized,

Wrap the template.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§