From e5fc327af0960c22615570a7489c15cb42e813c7 Mon Sep 17 00:00:00 2001 From: Alessandro Campeis <12007735+campeis@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:05:13 +0100 Subject: [PATCH] update handlebars to version 5.1 --- Cargo.lock | 34 ++++++++++++++++++++++--------- templating/fluent/Cargo.toml | 4 ++-- templating/fluent/src/main.rs | 13 +++++++++--- templating/handlebars/Cargo.toml | 2 +- templating/handlebars/src/main.rs | 11 ++++++++-- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d221e19b..4e30c3a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -984,7 +984,7 @@ dependencies = [ "fast_chemail", "fnv", "futures-util", - "handlebars", + "handlebars 4.5.0", "http 0.2.9", "indexmap 2.1.0", "mime", @@ -3168,24 +3168,24 @@ dependencies = [ [[package]] name = "fluent-template-macros" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7592cd1f45c1afe9084ce59c62a3a7c266c125c4c2ec97e95b0563c4aa914" +checksum = "0c58fd7421bad2b89506827409317a3088b74d0d637202003f2e87efdc43ae8e" dependencies = [ "flume 0.10.14", "ignore", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", "unic-langid", ] [[package]] name = "fluent-templates" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3ef2c2152757885365abce32ddf682746062f1b6b3c0824a29fbed6ee4d080" +checksum = "fc023356542b155925aa5e433806ddd33acb46f0218541f869b342676332cd79" dependencies = [ "arc-swap", "fluent", @@ -3194,7 +3194,7 @@ dependencies = [ "fluent-syntax", "fluent-template-macros", "flume 0.10.14", - "handlebars", + "handlebars 5.1.0", "heck", "ignore", "intl-memoizer", @@ -3678,6 +3678,20 @@ name = "handlebars" version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "handlebars" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4" dependencies = [ "log", "pest", @@ -7601,7 +7615,7 @@ dependencies = [ "actix-web", "actix-web-lab", "fluent-templates", - "handlebars", + "handlebars 5.1.0", "serde", "serde_json", ] @@ -7611,7 +7625,7 @@ name = "templating-handlebars" version = "1.0.0" dependencies = [ "actix-web", - "handlebars", + "handlebars 5.1.0", "serde_json", ] @@ -8261,7 +8275,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] diff --git a/templating/fluent/Cargo.toml b/templating/fluent/Cargo.toml index f6ed7ce4..e1a73a2e 100644 --- a/templating/fluent/Cargo.toml +++ b/templating/fluent/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] actix-web.workspace = true actix-web-lab.workspace = true -fluent-templates = { version = "0.8", features = ["handlebars"] } -handlebars = { version = "4.5", features = ["dir_source"] } +fluent-templates = { version = "0.9", features = ["handlebars"] } +handlebars = { version = "5.1", features = ["dir_source"] } serde.workspace = true serde_json.workspace = true diff --git a/templating/fluent/src/main.rs b/templating/fluent/src/main.rs index 8732a35e..9cd78745 100644 --- a/templating/fluent/src/main.rs +++ b/templating/fluent/src/main.rs @@ -10,7 +10,7 @@ use actix_web::{ }; use actix_web_lab::{extract::Path, respond::Html}; use fluent_templates::{static_loader, FluentLoader, Loader as _}; -use handlebars::Handlebars; +use handlebars::{DirectorySourceOptions, Handlebars}; use serde_json::json; mod lang_choice; @@ -57,7 +57,14 @@ async fn main() -> io::Result<()> { // register template dir with Handlebars registry handlebars - .register_templates_directory(".html", "./templates") + .register_templates_directory( + "./static/templates", + DirectorySourceOptions { + tpl_extension: ".html".to_owned(), + hidden: false, + temporary: false, + }, + ) .unwrap(); // register Fluent helper with Handlebars registry @@ -85,7 +92,7 @@ fn error_handlers() -> ErrorHandlers { // Error handler for a 404 Page not found error. fn not_found(res: ServiceResponse) -> Result> { let lang = LangChoice::from_req(res.request()).lang_id(); - let error = LOCALES.lookup(&lang, "error-not-found").unwrap(); + let error = LOCALES.lookup(&lang, "error-not-found"); let response = get_error_response(&res, &error); diff --git a/templating/handlebars/Cargo.toml b/templating/handlebars/Cargo.toml index 374e29c0..7b64c60c 100644 --- a/templating/handlebars/Cargo.toml +++ b/templating/handlebars/Cargo.toml @@ -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 diff --git a/templating/handlebars/src/main.rs b/templating/handlebars/src/main.rs index 3e4bb1b6..abffed28 100644 --- a/templating/handlebars/src/main.rs +++ b/templating/handlebars/src/main.rs @@ -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);