Replies: 3 comments 8 replies
-
We are gonna have to make breaking changes anyway. I think we should roll this change, #1646 and similar changes together to avoid breaking too much every release. |
Beta Was this translation helpful? Give feedback.
-
Not a huge fan of this, but can see the benefits. Mostly because my projects are getting big, and this will be a lot of typing/regex gymnastics.
Okay with the extra typing if it makes this possible. Though one worry is my html formatter may get confused.
Personally this would be incredibly useful. I only put local variables inside |
Beta Was this translation helpful? Give feedback.
-
let foo = "Hello world!".to_owned();
html! {
<div data-foo={&foo}/> // Borrow checker error
}
let foo = "Hello world!".to_owned();
html! {
<div data-foo=(&foo)/>
}
This isn't correct, see replies. |
Beta Was this translation helpful? Give feedback.
-
This proposal makes braces required around prop values:
This makes it possible to use the
..
operator instead ofwith
for specifying extra props: #1636To make it more ergonomic, literals (such as
"a string"
,123
,123usize
,false
etc...) should be allowed without any braces (same as current syntax).As a bonus (inspired by svelte), we could also allow a shorthand syntax when the prop is the same value as an identifier name:
(svelte docs)
For normal components, I doubt this would be too useful because local variables are relatively rare in the
view
function. However, this would be immensely useful with functional components because all state are stored as if they were local variables.Pros
..
syntax for destructuring props (Use Rust's..
syntax instead ofwith
inhtml!
#1636)html!
syntax more consistent. Html blocks already require curly braces around expressions.disabled
)Cons
Please react with 👍 or 👎. If you have further opinions on whether this is a good or bad idea, feel free to respond in the thread.
Beta Was this translation helpful? Give feedback.
All reactions