Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implicit snippet props are ambiguous#16207

darrylyeo started this conversation inIdeas
Discussion options

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{@attach}):

<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.

You must be logged in to vote

Replies: 1 comment

Comment options

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>
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Ideas
Labels
None yet
2 participants
@darrylyeo@Ocean-OS

[8]ページ先頭

©2009-2025 Movatter.jp