Skip to content

Commit

Permalink
fix: fixed cast issues with t! interpolation
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Changed delimiter in `t!` macro variable interpolation
from `:` to `=` to solve compiler misinterpretation errors
  • Loading branch information
arctic-hen7 committed Jun 29, 2022
1 parent 80523a4 commit 2cae13a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/core/i18n/src/templates/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn index_page<G: Html>(cx: Scope) -> View<G> {

view! { cx,
p { (t!("hello", {
"user": username
"user" = username
}, cx)) }
a(href = link!("/about", cx)) { "About" }
}
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus/src/translator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ macro_rules! t {
};
// When there are arguments to interpolate
($id:expr, {
$($key:literal: $value:expr),+
// NOTE Using a colon here leads to literally impossible to solve cast errors based on compiler misinterpretations
$($key:literal = $value:expr),+
}, $cx:expr) => {{
let mut args = $crate::internal::i18n::TranslationArgs::new();
$(
Expand Down

0 comments on commit 2cae13a

Please sign in to comment.