[−][src]Trait tide_tera::TideTeraExt
This extension trait adds two methods to tera::Tera:
render_response and
render_body
Required methods
pub fn render_response(&self, template_name: &str, context: &Context) -> Result[src]
render_body returns a fully-rendered [tide::Body] with mime
type set based on the template name file extension using the
logic at [tide::http::Mime::from_extension]. This will
return an Err variant if the render was unsuccessful.
use tide_tera::prelude::*; let tera = tera::Tera::new("tests/templates/**/*").unwrap(); let response = tera .render_response("good_template.html", &context! { "name" => "tide" }) .unwrap(); assert_eq!(response.content_type(), Some(tide::http::mime::HTML));
pub fn render_body(
&self,
template_name: &str,
context: &Context
) -> Result<Body>[src]
&self,
template_name: &str,
context: &Context
) -> Result<Body>
render_response returns a tide Response with a body rendered
with render_body. This will
return an Err variant if the render was unsuccessful.
use tide_tera::prelude::*; let tera = tera::Tera::new("tests/templates/**/*").unwrap(); let body = tera .render_body("good_template.html", &context! { "name" => "tide" }) .unwrap(); assert_eq!(body.mime(), &tide::http::mime::HTML);
Implementations on Foreign Types
impl TideTeraExt for Tera[src]
pub fn render_body(
&self,
template_name: &str,
context: &Context
) -> Result<Body>[src]
&self,
template_name: &str,
context: &Context
) -> Result<Body>