Skip to content

How to create an intermediate variable for multiple use in {#each} block? #4614

@angryziber

Description

@angryziber

Sometimes you need to calculate/retrieve something while iterating with {#each}.
It would be nice to be able to reuse this calculation, if it needs to be used multiple times, e.g.:

{#each sections as section}
  {#with url = '/path/to/' + section}
    <a href={url}>{url}</a>
  {/with}
{/each}

Is there something in current svelte that would enable this? Or can someting like this {#with} added?

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