From ff70307869a547b13850d1eec3f72e8ca3bca265 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 29 Jun 2026 03:31:44 +0800 Subject: feat: add display block support and refactor tests Deprecate old macros in favor of new deprecated module, replace the external file-based test with inline unit tests, and introduce the `??? >>>` / `??? <<<` display block syntax for conditional content inclusion per arm or globally. --- src/deprecated.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/deprecated.rs (limited to 'src/deprecated.rs') diff --git a/src/deprecated.rs b/src/deprecated.rs new file mode 100644 index 0000000..b218969 --- /dev/null +++ b/src/deprecated.rs @@ -0,0 +1,45 @@ +#[macro_export] +macro_rules! tmpl_param { + ($template:ident, $($key:ident = $value:expr),* $(,)?) => {{ + $( + $template.insert_param(stringify!($key).to_string(), $value.to_string()); + )* + }}; +} + +#[macro_export] +macro_rules! tmpl { + ($template:ident, $($name:ident { + $($key:ident = $value:expr),* $(,)? + }),* $(,)?) => {{ + $( + let $name = $template.add_impl(stringify!($name).to_string()); + $( + $name.push({ + let mut params = std::collections::HashMap::new(); + params.insert(stringify!($key).to_string(), $value.to_string()); + params + }); + )* + )* + }}; + + // Old syntax + ($template:ident += { + $($name:ident { + $(($($key:ident = $value:expr),* $(,)?)),* + $(,)? + }),* + }) => {{ + $( + let $name = $template.add_impl(stringify!($name).to_string()); + $( + $name.push({ + let mut params = std::collections::HashMap::new(); + $(params.insert(stringify!($key).to_string(), $value.to_string());)* + params + }); + )* + )* + }}; +} -- cgit