jeudi 20 juillet 2017

Iron renders html as text

A part of my iron web application looks like as follows:

lazy_static! {
    pub static ref TEMPLATES: Tera = {
        let mut tera = compile_templates!("templates/**/*");
        tera.autoescape_on(vec!["html", ".sql"]);
        tera
    };
}

fn index(_: &mut Request) -> IronResult<Response> {
    let ctx = Context::new();
    Ok(Response::with((iron::status::Ok, TEMPLATES.render("home/index.html", &ctx).unwrap())))
}

It renders an html template as text in a browser. Why not html and how to fix it?




Aucun commentaire:

Enregistrer un commentaire