-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Ability to pass scoped slots to descedants in templates #7178
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
Comments
Hello, |
The first version has some drawbacks:
This is not about just transform. The first case compiles to this (not actual output, but pseudo to show difference):
The second should compile to this:
|
Also note that this
and even this
does not works in Vue versions prior to 2.5.0, as I found out today. It's just my suggested workaround which works by accident. No guarantee it won't be broken in future versions. |
@shameleo - I've just hit the same problem, I think some sort of feature along the lines suggested is an excellent idea. Aside from the (valid) drawbacks you highlight there is the basic problem of having repeated boilerplate, in my case it's down a few generations. Also the current boilerplate might reducing composability, we've several components we're "injecting" via into a common component UI used across projects, even with the current two slots it's ugly. |
See #7765 |
What problem does this feature solve?
The related issue (#5151) is closed, so I need to clarify my point.
It should exist convenient way to define template for items of hierarchical component (for example, tree or list with sections).
I know, it can be solved with render functions, but it is not so "native" way of building components in vue as in react. I mean, writing / reading render functions is more uncomfortable for average vue user, because they are used only occasionally. It's even worse, if user need to setup webpack / babel / jsx. So I think, render functions should be avoided for not-so-advanced cases.
Slots can be "passed" to children using templates, like this:
But there are some drawbacks:
What does the proposed API look like?
Remark
I propose syntax, which is boiled down version of first markup, and can be supported by compiler. Here is my test implementation (it seems quite easy): shameleo/vue-slot-pass-demo@bdb6cbb
If you give me green light, I'll try to prepare PR. If something is missed in implementation, let me know, please.
The text was updated successfully, but these errors were encountered: