Closed as not planned
Description
Describe the problem
It is common to test a value to see what it is equal to, using multiple if/else blocks. However this can get tedious and repetitive quickly. Example:
{#if value === "Hi"}
Oh, hello!
{:else if value === "Bye"}
Goodbye!
{:else}
I don't understand...
{/if}
Describe the proposed solution
A {#switch }
block would be useful. It would work like the JS switch
block. Here's an example:
{#switch value break}
{:case "Hi"}
Oh, hello!
{:case "Bye"}
Goodbye!
{:default}
I don't understand...
{/switch}
The break
part in the {#switch }
block means that it breaks at the end of each {:case}
block. If this is not in the switch block, a {:break}
block can be used to break at the end of a case block. Here's a revision of the code above using {:break}
blocks:
{#switch value}
{:case "Hi"}
Oh, hello!
{:break}
{:case "Bye"}
Goodbye!
{:break}
{:default}
I don't understand...
{/switch}
Importance
would make my life easier
Gorbulev-Sergey
Metadata
Metadata
Assignees
Labels
No labels