{"id":13805648,"url":"https://github.com/l-portet/svelte-switch-case","last_synced_at":"2025-10-25T00:30:26.400Z","repository":{"id":49649145,"uuid":"517601008","full_name":"l-portet/svelte-switch-case","owner":"l-portet","description":"Switch case syntax for Svelte ⚡️","archived":false,"fork":false,"pushed_at":"2023-06-23T12:20:39.000Z","size":878,"stargazers_count":146,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-09-29T11:54:16.061Z","etag":null,"topics":["preprocess","svelte","sveltejs","sveltekit","switch-case"],"latest_commit_sha":null,"homepage":"https://svelte-switch-case.netlify.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/l-portet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-07-25T09:31:29.000Z","updated_at":"2024-09-20T19:53:41.000Z","dependencies_parsed_at":"2024-04-09T23:48:37.815Z","dependency_job_id":"02a67981-96e2-4d4b-8b34-c05d613076e0","html_url":"https://github.com/l-portet/svelte-switch-case","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l-portet%2Fsvelte-switch-case","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l-portet%2Fsvelte-switch-case/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l-portet%2Fsvelte-switch-case/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l-portet%2Fsvelte-switch-case/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/l-portet","download_url":"https://codeload.github.com/l-portet/svelte-switch-case/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867385,"owners_count":16555891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["preprocess","svelte","sveltejs","sveltekit","switch-case"],"created_at":"2024-08-04T01:01:03.405Z","updated_at":"2025-10-25T00:30:25.866Z","avatar_url":"https://github.com/l-portet.png","language":"TypeScript","funding_links":[],"categories":["Integrations"],"sub_categories":["Preprocessing"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.ibb.co/ZTTXt2Y/svelte-switch-case.png\" alt=\"\"  /\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eSvelte switch case\u003c/h1\u003e\n\u003cp align=\"center\"\u003eSwitch case syntax for your \u003ca href=\"https://svelte.dev/\"\u003eSvelte\u003c/a\u003e components.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://badgen.net/github/license/l-portet/svelte-switch-case?color=orange\" /\u003e\n  \u003cimg src=\"https://badgen.net/npm/v/svelte-switch-case\" /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://svelte-switch-case.netlify.app/\"\u003eDemo\u003c/a\u003e · \u003ca href=\"https://stackblitz.com/edit/svelte-switch-case?file=src/routes/index.svelte\"\u003eStackBlitz\u003c/a\u003e · \u003ca href=\"https://npmjs.com/package/svelte-switch-case\"\u003eNPM Package\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n## :zap: Getting started\n\n**Step 1:** Add the preprocessor to your Svelte project\n\n```bash\n# Install it:\nnpm i -D svelte-switch-case\n```\n```javascript\n// Then, in your svelte.config.js\nimport switchCase from 'svelte-switch-case';\n\nconst config = {\n  preprocess: [switchCase()],\n};\n\nexport default config;\n```\n\n**Step 2:** Start using it in your Svelte components\n\n```html\n\u003c!-- Component.svelte --\u003e\n\u003cscript\u003e\n  let animal = 'dog';\n\u003c/script\u003e\n\n\u003csection\u003e\n  {#switch animal}\n    {:case \"cat\"}\n      \u003cp\u003emeow\u003c/p\u003e\n    {:case \"dog\"}\n      \u003cp\u003ewoof\u003c/p\u003e\n    {:default}\n      \u003cp\u003eoink?\u003c/p\u003e\n  {/switch}\n\u003c/section\u003e\n```\n\n\u003cbr /\u003e\n\n## :mag: How it works\n\n`svelte-switch-case` transpiles the following code\n\n```html\n{#switch animal}\n  {:case \"cat\"}\n    \u003cp\u003emeow\u003c/p\u003e\n  {:case \"dog\"}\n    \u003cp\u003ewoof\u003c/p\u003e\n  {:default}\n    \u003cp\u003eoink?\u003c/p\u003e\n{/switch}\n```\n\ninto `if/else` statements\n\n```html\n\u003c!-- Injected by svelte-switch-case --\u003e\n{#if animal === \"cat\"}\n  \u003cp\u003emeow\u003c/p\u003e\n{:else if animal === \"dog\"}\n  \u003cp\u003ewoof\u003c/p\u003e\n{:else}\n  \u003cp\u003eoink?\u003c/p\u003e\n{/if}\n```\n\n\u003cbr /\u003e\n\n## :raised_hands: Contribute\nFound a bug or just had a cool idea? Feel free to [open an issue](https://github.com/l-portet/svelte-switch-case/issues) or [submit a PR](https://github.com/l-portet/svelte-switch-case/pulls).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-portet%2Fsvelte-switch-case","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl-portet%2Fsvelte-switch-case","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-portet%2Fsvelte-switch-case/lists"}