From 246f239d9f40f633160f0c18f87a20922d4e77bb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:06:37 +0200 Subject: Merging debian version 1.65.0+dfsg1-2. Signed-off-by: Daniel Baumann --- vendor/handlebars/tests/helper_macro.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'vendor/handlebars/tests/helper_macro.rs') diff --git a/vendor/handlebars/tests/helper_macro.rs b/vendor/handlebars/tests/helper_macro.rs index 9a8d2dc07..cc5ed914b 100644 --- a/vendor/handlebars/tests/helper_macro.rs +++ b/vendor/handlebars/tests/helper_macro.rs @@ -4,6 +4,8 @@ extern crate handlebars; extern crate serde_json; use handlebars::Handlebars; +use time::format_description::{parse, well_known::Rfc2822}; +use time::OffsetDateTime; handlebars_helper!(lower: |s: str| s.to_lowercase()); handlebars_helper!(upper: |s: str| s.to_uppercase()); @@ -14,6 +16,7 @@ handlebars_helper!(nargs: |*args| args.len()); handlebars_helper!(has_a: |{a:i64 = 99}, **kwargs| format!("{}, {}", a, kwargs.get("a").is_some())); handlebars_helper!(tag: |t: str| format!("<{}>", t)); +handlebars_helper!(date: |dt: OffsetDateTime| dt.format(&parse("[year]-[month]-[day]").unwrap()).unwrap()); #[test] fn test_macro_helper() { @@ -26,6 +29,7 @@ fn test_macro_helper() { hbs.register_helper("nargs", Box::new(nargs)); hbs.register_helper("has_a", Box::new(has_a)); hbs.register_helper("tag", Box::new(tag)); + hbs.register_helper("date", Box::new(date)); let data = json!("Teixeira"); @@ -73,4 +77,13 @@ fn test_macro_helper() { hbs.render_template("{{{tag \"html\"}}}", &()).unwrap(), "" ); + + assert_eq!( + hbs.render_template( + "{{date this}}", + &OffsetDateTime::parse("Wed, 18 Feb 2015 23:16:09 GMT", &Rfc2822).unwrap() + ) + .unwrap(), + "2015-02-18" + ); } -- cgit v1.2.3