{"id":26124,"library":"pug-to-svelte","title":"pug-to-svelte","description":"Pug-to-Svelte transpiler (v1.1.0, stable, complete). Converts Pug templates to HTML while preserving Svelte logic, expressions, and control structures. Designed as a Svelte preprocessor. Key limitations: tabs-only indentation, no tag splitting across lines, no prop shorthands, no spread props, no style props. Production-ready and actively maintained but feature-complete. Faster and lighter than generic template transpilers, with zero artificial syntax.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","preprocess","pug","svelte","transpile"],"install":[{"cmd":"npm install pug-to-svelte","lang":"bash","label":"npm"},{"cmd":"yarn add pug-to-svelte","lang":"bash","label":"yarn"},{"cmd":"pnpm add pug-to-svelte","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Pug template parsing.","package":"pug","optional":false}],"imports":[{"note":"Package exports a single function as default export. Named import will fail.","wrong":"import { pugToSvelte } from 'pug-to-svelte'","symbol":"default export","correct":"import pugToSvelte from 'pug-to-svelte'"},{"note":"CommonJS require works directly, no .default needed.","wrong":"const pugToSvelte = require('pug-to-svelte').default","symbol":"require","correct":"const pugToSvelte = require('pug-to-svelte')"},{"note":"Package ships TypeScript declarations. Use ESM import for proper type inference. For CJS, use const pugToSvelte: any = require('pug-to-svelte').","wrong":"import pugToSvelte = require('pug-to-svelte')","symbol":"TypeScript types","correct":"import pugToSvelte from 'pug-to-svelte'"}],"quickstart":{"code":"import pugToSvelte from 'pug-to-svelte';\n\nconst pugCode = `\nscript.\n  let count = 0\n\nbutton(on:click={() => count++}) Clicked {count} times\n`;\n\ntry {\n  const htmlResult = pugToSvelte(pugCode);\n  console.log(htmlResult); // Output: Svelte component with HTML\n} catch (error) {\n  console.error('Transpilation failed:', error);\n}\n\n// Use with Svelte preprocessor:\nimport { preprocess } from 'svelte/compiler';\nimport { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\n\nconst preprocessed = await preprocess(\n  pugCode,\n  vitePreprocess(),\n  { filename: 'Component.svelte' }\n);\nconsole.log(preprocessed.code);","lang":"typescript","description":"Transpile a simple Pug template to Svelte HTML, including error handling and integration with Svelte preprocessors."},"warnings":[{"fix":"Convert indentation to tabs. Most editors have a 'Convert Indentation to Tabs' option.","message":"Indentation must use tabs only. Spaces as indentation will cause parse errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure each tag (including attributes) is on one line.","message":"Tags cannot be split across multiple lines. Each tag must be on a single line.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always explicitly write both prop name and value: `value={value}`.","message":"Prop shorthands (e.g., `{value}` instead of `value={value}`) are NOT supported. Svelte-style shorthands like `{value}` will not work.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Expand props manually or use a wrapper component.","message":"Spread props (e.g., `{...obj}`) are NOT supported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use inline styles via the `style` attribute as an object string.","message":"Style props (like `style:color`) are NOT supported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No action needed, but evaluate if other transpilers (like svelte-preprocess with pug) suit your needs.","message":"This package is feature-complete and no further development is planned.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace spaces with tabs for indentation in your .svelte files using Pug syntax.","cause":"Using spaces for indentation instead of tabs.","error":"Error: Unexpected token 'div' at ..."},{"fix":"Put the entire tag (including attributes) on a single line.","cause":"A tag is split across multiple lines.","error":"Error: Expected newline or indentation but got something else at line X"},{"fix":"Use `import pugToSvelte from 'pug-to-svelte'` or `const pugToSvelte = require('pug-to-svelte')`.","cause":"Using named import instead of default import.","error":"TypeError: pugToSvelte is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}