Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.6k
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I'm not a fan ofimplicit snippet props on components because they'rereally easy to confuse with a "locally-declared" snippet meant to be used in children markup: <Sectionsize="large"> {#snippettitle()} My Section Title {/snippet} {#snippettag(content)} {content} {/snippet} {@rendertag('Hello')} {@rendertag('World')}</Section> Instead I think snippet props should be applied within the component's opening tag (similar to <Sectionsize="large" {#snippettitle()}MySectionTitle {/snippet}> {#snippettag(content)} {content} {/snippet} {@rendertag('Hello')} {@rendertag('World')}</Section> Or maybe something like an "anonymous" snippet? (Would have to figure out a workable syntax): <Sectionsize="large"title={ {#snippet()}MySectionTitle {/snippet} }> {#snippettag(content)} {content} {/snippet} {@rendertag('Hello')} {@rendertag('World')}</Section> This better conveys that a snippet is a one-off implementation intended only for use as a prop for a particular component instance. |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment
-
I feel like that'd either discourage people from making large snippets or result in overly complex code. If you want to prevent helper snippets from becoming props, you could do something like this, where you put the helper inside the snippet: <Component>{#snippetchildren()} {#snippethelper()} ... {/snippet} {@renderhelper()}{/snippet}</Component> |
BetaWas this translation helpful?Give feedback.