Skip to content

Switch statements for declaring reactive pages #6260

Closed
@TheBlueOompaLoompa

Description

@TheBlueOompaLoompa

Is your feature request related to a problem? Please describe.
I'm trying to create a page with multiple login steps, it would be great if I could just use a switch block instead of multiple if blocks.

Describe the solution you'd like

<script>
  var x = 'first'
</script>
{#switch x}
  {:case 'first'}
    <h1>First</h1>
  {:case 'second}
    <h2>Second</h2>
{/switch}

Describe alternatives you've considered
I have tried svelte client side rendering, but that won't work in the current case because I'm using Sveltekit.

How important is this feature to you?
It would be nice but unnecessary, I know a lot of svelte is about being fast, and sleek. This would make the developer experience a lot faster. I have also heard that switch statements are faster than if statements.

Additional context
In this case I just need to switch between small blocks of HTML, so it wouldn't be too much bigger than normal

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