-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Cannot prepopulate snippet arguments #13610
Comments
This is the one feature I would like to see added the most - duplicate of: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the problem
I have a snippet creating a general element with multiple arguments:
I wanted to pass different variations of this snippet to a child component, but with prepopulated values for
label
andicon
:While typing this works great with TypeScript, and
svelte-check
does not report any errors, a runtime error is thrown:I Tried this
Neither specifying the prepopulated function/snippet (like above), nor defining a
function homeItem(selected: boolean) { ... }
in the<script>
works.I guess this is expected, since it seems that snippets are not "simply functions", and are interpreted differently.
I believe that
createRawSnippet
can not solve this, since it has to return valid HTML (?), and can not return/render a another snippet?The only solution currenly
The only solution is to create (in this example) two more
{#snippet}
s forhome
andsettings
and pass these to theChild
instead of composing the Snippet in-line.Proposed Solution
I understand that one can not define a snippet inside
<script>
, as we require the HTML-like syntax of the template, but it would be great if snippets were them "composable" (prepopulate-able) inside JS/TS.Importance
would make my life easier
The text was updated successfully, but these errors were encountered: