Trait tide_tera::TideTeraExt [−][src]
This extension trait adds two methods to tera::Tera
:
render_response
and
render_body
Required methods
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));
fn render_body(&self, template_name: &str, context: &Context) -> Result<Body>
[src]
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);