Switch case syntax for Svelte
npm install svelte-switch-case

Switch case syntax for your Svelte components.
Demo · StackBlitz · NPM Package
Step 1: Add the preprocessor to your Svelte project
``bash`Install it:
npm i -D svelte-switch-case`javascript
// Then, in your svelte.config.js
import switchCase from 'svelte-switch-case';
const config = {
preprocess: [switchCase()],
};
export default config;
`
Step 2: Start using it in your Svelte components
`html
meow woof oink?
{#switch animal}
{:case "cat"}
{:case "dog"}
{:default}
{/switch}
`
svelte-switch-case transpiles the following code
` meow woof oink?html`
{#switch animal}
{:case "cat"}
{:case "dog"}
{:default}
{/switch}
into if/else statements
` meow woof oink?html``
{#if animal === "cat"}
{:else if animal === "dog"}
{:else}
{/if}