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
On top of creating many single-use variables (if rendered more than once), which can lead to mistakes, it's also just a very labored way of doing it. It's problematic to the point where it almost makes more sense to copy-paste the contents of the snippet to avoid those issues.
One way to fix the problem would be to allow for @render to receive children, like so:
Snippets' parameter names currently have no impact on how these parameters are passed, since they're set up like functions. That would need to change in order to receive snippets (and children) by name, which seems like a pretty big undertaking;
The @render tag would now need to be written as #render, though it could simply support both ways;
If this were to be implemented, there'd be very little separating a snippet from a component other than scale.
Another way would be to pass anonymous snippets directly in the @render call, like so:
This would circumvent the first two issues above, but it would mean blending HTML into what I think is supposed to only accept JS, which seems to be something Svelte managed to avoid doing up until now.
I had originally planned to post this as a feature request, but since I'm undecided as to which feature should be introduced, if any at all, I think I'll defer to the more experienced Svelte devs as to how to solve this problem.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've seen this topic mentioned in #15822, but I feel it could be better discussed as a potential feature rather than a question.
Currently, if I need to pass a snippet as a parameter to a
@render
tag, I need to declare it beforehand, like so:On top of creating many single-use variables (if rendered more than once), which can lead to mistakes, it's also just a very labored way of doing it. It's problematic to the point where it almost makes more sense to copy-paste the contents of the snippet to avoid those issues.
One way to fix the problem would be to allow for
@render
to receive children, like so:This approach would have a few problems:
@render
tag would now need to be written as#render
, though it could simply support both ways;Another way would be to pass anonymous snippets directly in the
@render
call, like so:This would circumvent the first two issues above, but it would mean blending HTML into what I think is supposed to only accept JS, which seems to be something Svelte managed to avoid doing up until now.
I had originally planned to post this as a feature request, but since I'm undecided as to which feature should be introduced, if any at all, I think I'll defer to the more experienced Svelte devs as to how to solve this problem.
Beta Was this translation helpful? Give feedback.
All reactions