mirror of
https://github.com/actix/examples
synced 2024-11-23 14:31:07 +01:00
update handlebars to version 5.1
This commit is contained in:
parent
2f7a1db615
commit
e5fc327af0
34
Cargo.lock
generated
34
Cargo.lock
generated
@ -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",
|
||||
]
|
||||
|
@ -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
|
||||
|
@ -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<BoxBody> {
|
||||
// Error handler for a 404 Page not found error.
|
||||
fn not_found<B>(res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<BoxBody>> {
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user