You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
How attribute values work is slightly inconsistent and rust-analyzer support isn't the best
Describe the solution you'd like
This was discussed briefly on discord:
1. Require braces for attribute values except for str/num/bool literals.
Right now you can do attr=arbitrary.expression() + thing - but this requires that the expression after the = is valid - if you write something like arbitrary., the macro won't expand and you don't get any autocomplete suggestions after the ..
This change would require any non-literal expressions to be wrapped in braces, like attr={arbitrary.expression() + thing}. This makes it easier to parse (just take everything inside the {}), providing r-a support even in incomplete expressions.
2. More consistent value shorthands
On HTML attributes, the attribute checked is equivalent to checked=true, while on leptos components, it is checked={checked}.
Make this consistent by making checked always equivalent to checked=true, and {checked} equivalent to checked={checked}.
Both of these changes are also what other frameworks like Svelte does.
Describe alternatives you've considered
staying with the current macro.
Additional context
My own view macro leptos-mview implements these requirements, and does have significantly better r-a support. Feel free to steal parts of my implementation for this change.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
How attribute values work is slightly inconsistent and rust-analyzer support isn't the best
Describe the solution you'd like
This was discussed briefly on discord:
1. Require braces for attribute values except for str/num/bool literals.
Right now you can do
attr=arbitrary.expression() + thing
- but this requires that the expression after the=
is valid - if you write something likearbitrary.
, the macro won't expand and you don't get any autocomplete suggestions after the.
.This change would require any non-literal expressions to be wrapped in braces, like
attr={arbitrary.expression() + thing}
. This makes it easier to parse (just take everything inside the{}
), providing r-a support even in incomplete expressions.2. More consistent value shorthands
On HTML attributes, the attribute
checked
is equivalent tochecked=true
, while on leptos components, it ischecked={checked}
.Make this consistent by making
checked
always equivalent tochecked=true
, and{checked}
equivalent tochecked={checked}
.Both of these changes are also what other frameworks like Svelte does.
Describe alternatives you've considered
staying with the current macro.
Additional context
My own view macro leptos-mview implements these requirements, and does have significantly better r-a support. Feel free to steal parts of my implementation for this change.
The text was updated successfully, but these errors were encountered: