Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7 attribute values #2196

Open
blorbb opened this issue Jan 18, 2024 · 2 comments
Open

0.7 attribute values #2196

blorbb opened this issue Jan 18, 2024 · 2 comments

Comments

@blorbb
Copy link
Contributor

blorbb commented Jan 18, 2024

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.

@jquesada2016
Copy link
Contributor

I like this!

@JonahLund
Copy link

Yes, I would love a stricter/more consistent view macro aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants