diff options
author | Matthew Taylor <wrapperup4@gmail.com> | 2023-07-24 05:39:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-24 11:39:14 +0200 |
commit | ac8de6260e34c7dc7f7f2228e832d1860a31707d (patch) | |
tree | dbdceecef23a2db606c6d5df33deefb783798686 /testing | |
parent | 31e9ed52bebb6d026dc3a8ae29c28af4beb7122e (diff) | |
download | askama-ac8de6260e34c7dc7f7f2228e832d1860a31707d.tar.gz askama-ac8de6260e34c7dc7f7f2228e832d1860a31707d.tar.bz2 askama-ac8de6260e34c7dc7f7f2228e832d1860a31707d.zip |
Fix Rust macro invocations not accepting a path (#837)
Diffstat (limited to 'testing')
-rw-r--r-- | testing/templates/rust-macros-full-path.html | 1 | ||||
-rw-r--r-- | testing/tests/rust_macro.rs | 24 |
2 files changed, 23 insertions, 2 deletions
diff --git a/testing/templates/rust-macros-full-path.html b/testing/templates/rust-macros-full-path.html new file mode 100644 index 0000000..f32dc53 --- /dev/null +++ b/testing/templates/rust-macros-full-path.html @@ -0,0 +1 @@ +Hello, {{ foo::hello2!() }}! diff --git a/testing/tests/rust_macro.rs b/testing/tests/rust_macro.rs index 2efe8be..1ee37e3 100644 --- a/testing/tests/rust_macro.rs +++ b/testing/tests/rust_macro.rs @@ -11,11 +11,31 @@ macro_rules! hello { struct RustMacrosTemplate {} #[test] -fn main() { +fn macro_basic() { let template = RustMacrosTemplate {}; assert_eq!("Hello, world!", template.render().unwrap()); } +mod foo { + macro_rules! hello2 { + () => { + "world" + }; + } + + pub(crate) use hello2; +} + +#[derive(Template)] +#[template(path = "rust-macros-full-path.html")] +struct RustMacrosFullPathTemplate {} + +#[test] +fn macro_full_path() { + let template = RustMacrosFullPathTemplate {}; + assert_eq!("Hello, world!", template.render().unwrap()); +} + macro_rules! call_a_or_b_on_tail { ((a: $a:expr, b: $b:expr, c: $c:expr), call a: $($tail:expr),*) => { ($a)($($tail),*) @@ -47,7 +67,7 @@ fn day(_: u16, _: &str, d: u8) -> u8 { struct RustMacrosArgTemplate {} #[test] -fn args() { +fn macro_with_args() { let template = RustMacrosArgTemplate {}; assert_eq!("2021\nJuly\n2", template.render().unwrap()); } |