1
0
mirror of https://github.com/actix/examples synced 2025-06-27 01:27:43 +02:00

add minijinja templating example

This commit is contained in:
Rob Ede
2022-10-16 21:20:01 +01:00
parent 6953e927ac
commit 5e8883e35a
11 changed files with 686 additions and 364 deletions

View File

@ -8,6 +8,7 @@ use actix_web::{
middleware::{self, ErrorHandlerResponse, ErrorHandlers},
web, App, Error, HttpResponse, HttpServer, Result,
};
use actix_web_lab::respond::Html;
use tera::Tera;
// store tera template in application state
@ -26,7 +27,8 @@ async fn index(
tmpl.render("index.html", &tera::Context::new())
.map_err(|_| error::ErrorInternalServerError("Template error"))?
};
Ok(HttpResponse::Ok().content_type("text/html").body(s))
Ok(Html(s))
}
#[actix_web::main]