A fork of Prettier (v2.8.8 base) that patches Handlebars formatting. Fixes conditional attribute blocks, one-line blocks, partial syntax, trailing slash in self-closing tags, and forces single quotes in expressions. Current version 3.1.7 supports Node >=14, ships TypeScript types, and is exclusively ESM. Unlike the official Prettier, this fork targets Handlebars projects that need specific HBS formatting fixes not accepted upstream. Release cadence is irregular; last update June 2023.
npm install prettier-hbsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Formats a Handlebars template using the glimmer parser with single quotes option. Uses ESM import syntax.
Switch to ESM imports (import ... from 'prettier-hbs') or use dynamic import().
Configure prettier-hbs overrides in your .prettierrc: { "overrides": [{ "files": "*.hbs", "options": { "parser": "glimmer" } }] }Refer to Prettier v2 documentation for supported options. Do not expect Prettier v3 features.
If you need double quotes in expressions, this fork may not suit your project. Consider upstream Prettier or another tool.
If you need no trailing newline or multiple newlines, post-process the output.
Run `npm install prettier-hbs` and use ESM import: `import { format } from 'prettier-hbs';`Switch to ESM: set `"type": "module"` in package.json or use dynamic import: `const prettier = await import('prettier-hbs');`Use named import: `import { format } from 'prettier-hbs';`Add to .prettierrc: `{ "overrides": [{ "files": "*.hbs", "options": { "parser": "glimmer" } }] }`No dependency data recorded yet.