diff options
author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-11-17 14:40:12 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-11-28 11:36:09 +0100 |
commit | 28e26751cef5ca5e3b0a0e6e8c8aadff92dc615b (patch) | |
tree | 3a7adf6392bf95cc849095974d669171576e95d5 /testing/tests/macro.rs | |
parent | b3020ee8bf979037e4191558ee7f1131b5c82de7 (diff) | |
download | askama-28e26751cef5ca5e3b0a0e6e8c8aadff92dc615b.tar.gz askama-28e26751cef5ca5e3b0a0e6e8c8aadff92dc615b.tar.bz2 askama-28e26751cef5ca5e3b0a0e6e8c8aadff92dc615b.zip |
Add tests for named arguments in macro calls
Diffstat (limited to 'testing/tests/macro.rs')
-rw-r--r-- | testing/tests/macro.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testing/tests/macro.rs b/testing/tests/macro.rs index faada37..0088f36 100644 --- a/testing/tests/macro.rs +++ b/testing/tests/macro.rs @@ -95,3 +95,31 @@ fn test_macro_self_arg() { let t = MacroSelfArgTemplate { s: "foo" }; assert_eq!(t.render().unwrap(), "foo"); } + +#[derive(Template)] +#[template( + source = "{%- macro thrice(param1, param2) -%} +{{ param1 }} {{ param2 }} +{% endmacro -%} + +{%- call thrice(param1=2, param2=3) -%} +{%- call thrice(param2=3, param1=2) -%} +{%- call thrice(3, param2=2) -%} +", + ext = "html" +)] +struct MacroNamedArg; + +#[test] +// We check that it's always the correct values passed to the +// expected argument. +fn test_named_argument() { + assert_eq!( + MacroNamedArg.render().unwrap(), + "\ +2 3 +2 3 +3 2 +" + ); +} |