- Notifications
You must be signed in to change notification settings - Fork3
Switch case syntax for Svelte ⚡️
License
NotificationsYou must be signed in to change notification settings
l-portet/svelte-switch-case
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Switch case syntax for yourSvelte components.
Step 1: Add the preprocessor to your Svelte project
# Install it:npm i -D svelte-switch-case// Then, in your svelte.config.jsimportswitchCasefrom'svelte-switch-case';constconfig={preprocess:[switchCase()],};exportdefaultconfig;
Step 2: Start using it in your Svelte components
<!-- Component.svelte --><script>letanimal='dog';</script><section> {#switch animal} {:case "cat"}<p>meow</p> {:case "dog"}<p>woof</p> {:default}<p>oink?</p> {/switch}</section>
svelte-switch-case transpiles the following code
{#switch animal} {:case "cat"}<p>meow</p> {:case "dog"}<p>woof</p> {:default}<p>oink?</p>{/switch}intoif/else statements
<!-- Injected by svelte-switch-case -->{#if animal === "cat"}<p>meow</p>{:else if animal === "dog"}<p>woof</p>{:else}<p>oink?</p>{/if}
Found a bug or just had a cool idea? Feel free toopen an issue orsubmit a PR.
About
Switch case syntax for Svelte ⚡️
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
