Skip to content

Consistent block params syntax #19

@NullVoxPopuli

Description

@NullVoxPopuli

I noticed in the README there is:

<h1>Cats of YouTube</h1>
<ul>
  {#each cats as cat}
    <li><a target="_blank" href={cat.video}>{cat.name}</a></li>
  {/each}
</ul>

and

{#each items as item, i}
  <p>{i}: {item.name}</p>
{/each}

and

{#each items as item (item.id)}
  <p>{item.name}</p>
{/each}

It would be good to unify the concept of "block params", so that there is only one syntax to mean "these are params passed to the block"

I propose:

{#each items as (item, i, params, here, example)}
  <p>{item.name}</p>
{/each}

and then for specifying the key, since that's a concern of each and not the block params, it should be closer to what each is iterating over.

{#each items key='id' as (item, i, params, here, , example)}
  <p>{item.name}</p>
{/each}

(this is in part inspired by the glimmer syntax, where the syntax is immensely narrow, but clear)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions