aboutsummaryrefslogtreecommitdiff
path: root/src/deprecated.rs
blob: b218969b50bc515433f8a83dd38d7340e569b15b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
                });
            )*
        )*
    }};
}