Replies: 1 comment
-
So this is sort of snippet composability, I suppose you can turn this into a feature request for more visibility if this hasn't been done before. You will most probably be asked for a legit use case though since the default alternative (using a component) already works well for most cases. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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