1
0
mirror of https://github.com/actix/examples synced 2025-08-30 17:50:21 +02:00

update handlebars to version 5.1

This commit is contained in:
Alessandro Campeis
2024-03-04 13:05:13 +01:00
parent 2f7a1db615
commit e5fc327af0
5 changed files with 46 additions and 18 deletions

View File

@@ -5,5 +5,5 @@ edition = "2021"
[dependencies]
actix-web.workspace = true
handlebars = { version = "4.5", features = ["dir_source"] }
handlebars = { version = "5.1", features = ["dir_source"] }
serde_json.workspace = true

View File

@@ -8,7 +8,7 @@ use actix_web::{
middleware::{ErrorHandlerResponse, ErrorHandlers},
web, App, HttpResponse, HttpServer, Result,
};
use handlebars::Handlebars;
use handlebars::{DirectorySourceOptions, Handlebars};
use serde_json::json;
// Macro documentation can be found in the actix_web_codegen crate
@@ -41,7 +41,14 @@ async fn main() -> io::Result<()> {
// Application Builder as an atomic reference-counted pointer.
let mut handlebars = Handlebars::new();
handlebars
.register_templates_directory(".html", "./static/templates")
.register_templates_directory(
"./static/templates",
DirectorySourceOptions {
tpl_extension: ".html".to_owned(),
hidden: false,
temporary: false,
},
)
.unwrap();
let handlebars_ref = web::Data::new(handlebars);