diff --git a/template_tera/Cargo.toml b/template_tera/Cargo.toml index 71ad8b95..607801c6 100644 --- a/template_tera/Cargo.toml +++ b/template_tera/Cargo.toml @@ -7,6 +7,6 @@ edition = "2018" [dependencies] env_logger = "0.6" -tera = "0.11" +tera = "1.0" actix-web = "2.0.0-alpha.6" actix-rt = "1.0.0" diff --git a/template_tera/src/main.rs b/template_tera/src/main.rs index fac0ac79..c2123edc 100644 --- a/template_tera/src/main.rs +++ b/template_tera/src/main.rs @@ -1,9 +1,7 @@ -#[macro_use] -extern crate tera; - use std::collections::HashMap; use actix_web::{error, middleware, web, App, Error, HttpResponse, HttpServer}; +use tera::Tera; // store tera template in application state async fn index( @@ -31,7 +29,7 @@ async fn main() -> std::io::Result<()> { HttpServer::new(|| { let tera = - compile_templates!(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")); + Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap(); App::new() .data(tera) diff --git a/todo/Cargo.toml b/todo/Cargo.toml index ae1f3598..43ac6b4b 100644 --- a/todo/Cargo.toml +++ b/todo/Cargo.toml @@ -17,7 +17,7 @@ log = "0.4.3" serde = "1.0.69" serde_derive = "1.0.69" serde_json = "1.0.22" -tera = "0.11.8" +tera = "1.0" [dependencies.diesel] features = ["postgres", "r2d2"] diff --git a/todo/src/api.rs b/todo/src/api.rs index 990af651..dd1d826b 100644 --- a/todo/src/api.rs +++ b/todo/src/api.rs @@ -26,7 +26,7 @@ pub async fn index( let rendered = tmpl .render("index.html.tera", &context) - .map_err(|e| error::ErrorInternalServerError(e.description().to_owned()))?; + .map_err(|e| error::ErrorInternalServerError(e))?; Ok(HttpResponse::Ok().body(rendered)) } diff --git a/todo/src/main.rs b/todo/src/main.rs index 5fc60974..54481e4e 100644 --- a/todo/src/main.rs +++ b/todo/src/main.rs @@ -4,8 +4,6 @@ extern crate diesel; extern crate log; #[macro_use] extern crate serde_derive; -#[macro_use] -extern crate tera; use std::{env, io}; @@ -37,7 +35,7 @@ async fn main() -> io::Result<()> { let app = move || { debug!("Constructing the App"); - let templates: Tera = compile_templates!("templates/**/*"); + let templates: Tera = Tera::new("/templates/**/*").unwrap(); let session_store = CookieSession::signed(SESSION_SIGNING_KEY).secure(false);