Skip to content

What's the "official" stance around how to work around binding of snippet parameters? #12620

Answered by brunnerh
webJose asked this question in Q&A
Discussion options

You must be logged in to vote

As long as you have an object, you can bind to its properties in snippets.

<script>
	let o1 = $state({ name: 'Tama' });
	let o2 = $state({ name: 'Pochi' });
</script>

{#snippet item(data)}
	<input bind:value={data.name} />
{/snippet}

{@render item(o1)} {o1.name} <br>
{@render item(o2)} {o2.name}

REPL

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@webJose
Comment options

Answer selected by webJose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants