Allow shorthand when passing params to templates
This commit is contained in:
parent
e6cc7ef606
commit
63d03f3afb
@ -40,7 +40,7 @@ async fn main() -> eyre::Result<()> {
|
|||||||
|
|
||||||
async fn say_hello(Path((lang, name)): Path<(String, String)>) -> impl IntoResponse {
|
async fn say_hello(Path((lang, name)): Path<(String, String)>) -> impl IntoResponse {
|
||||||
Rendered(render_template_string!(TEMPLATING, say_hello, lang, {
|
Rendered(render_template_string!(TEMPLATING, say_hello, lang, {
|
||||||
name: name
|
name
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,8 +216,15 @@ macro_rules! interpreter_setters {
|
|||||||
{ $params:ident; $k:ident : $v:expr } => {
|
{ $params:ident; $k:ident : $v:expr } => {
|
||||||
$params = $params.set(stringify!($k), $v);
|
$params = $params.set(stringify!($k), $v);
|
||||||
};
|
};
|
||||||
|
{ $params:ident; $k:ident } => {
|
||||||
|
$params = $params.set(stringify!($k), $k);
|
||||||
|
};
|
||||||
{ $params:ident; $k:ident : $v:expr, $($tail:tt)* } => {
|
{ $params:ident; $k:ident : $v:expr, $($tail:tt)* } => {
|
||||||
$params = $params.set(stringify!($k), $v);
|
$params = $params.set(stringify!($k), $v);
|
||||||
interpreter_setters!{ $params; $($tail)* }
|
interpreter_setters!{ $params; $($tail)* }
|
||||||
};
|
};
|
||||||
|
{ $params:ident; $k:ident, $($tail:tt)* } => {
|
||||||
|
$params = $params.set(stringify!($k), $k);
|
||||||
|
interpreter_setters!{ $params; $($tail)* }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user