-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Shorthand if/each/... #3288
Comments
Thanks, but this does introduce extra complexity, both for the compiler and for people using Svelte. We aim to just have one way to do things wherever possible, otherwise it increases the amount of stuff that people have to learn, and makes the documentation more unwieldy |
Hmm, one year later. I'm coming from Riotjs where we had this
Maybe I'm just "doing it wrong" but e.g. modifying the submit button seems overly verbose:
Upon revisiting, especially with auto-completion on vscode Still, the extreme shorthand for (the |
I would like to get this issue re-opened @Rich-Harris ."
I get this point of view, but due to the popularity of other languages I almost want to make the point that it doesn't increase the amount of stuff that people have to learn. Most people who start using Svelte come from In the case that they are completely new to front-end development; Why not consider this syntactic sugar? It should literally function the same as if the logic block was wrapping around the element it was added on. This would be the perfect opportunity for people to get started using 'eslint' where using this kind of syntax could throw a warning if desired. The extra added complexity to the compiler, due to the context and existence of the current logic blocks, I assume isn't "that" much as it has to go over all the element attributes anyways and in that case already knows what element is the target of the shorthand logic blocks. I want this to be added not because other popular frameworks do it, but because it is easier to read, in some cases more maintainable and generally speaking easier to the eyes when you also have other attributes and event handlers on the same element.
Is there something else that I'm missing here? |
totally agree. Pls do reopen this case. |
This syntax is my least favorite part of svelte, I would even create a wrapper component so i dont have to look at it <s if={true}>
<div.../>
</s> |
I was thinking if there should exists a shorthand version for logic blocks, it would be an simple alternative to have for small blocks of code. Currently it looks like this
What I had in mind was something that already exists in Angular or similar, like
How important is this feature to you?
It isn't very important, just a thought and basically starting a discussion. This probably adds another paradigm to Svelte hence increasing the complexity for the compiler, hence would love to hear others opinion
The text was updated successfully, but these errors were encountered: