{"id":41768,"library":"prettier-hbs","title":"prettier-hbs","description":"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.","status":"active","version":"3.1.7","language":"javascript","source_language":"en","source_url":"https://github.com/falsefalse/prettier-hbs","tags":["javascript","typescript"],"install":[{"cmd":"npm install prettier-hbs","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-hbs","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-hbs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v3. CommonJS require will fail.","wrong":"const { format } = require('prettier-hbs')","symbol":"format","correct":"import { format } from 'prettier-hbs'"},{"note":"Used to load .prettierrc configuration programmatically.","symbol":"resolveConfig","correct":"import { resolveConfig } from 'prettier-hbs'"},{"note":"Default export is the same as the module namespace. Named exports are also available.","wrong":"import * as prettier from 'prettier-hbs'","symbol":"default (named export)","correct":"import prettier from 'prettier-hbs'"},{"note":"Options type is only available as a type import in TypeScript.","wrong":"import { Options } from 'prettier-hbs'","symbol":"config options (TypeScript)","correct":"import type { Options } from 'prettier-hbs'"}],"quickstart":{"code":"import { format } from 'prettier-hbs';\n\nconst hbsCode = `<div>\n  {{#if condition}}\n    <span>{{name}}</span>\n  {{/if}}\n</div>`;\n\nconst formatted = await format(hbsCode, {\n  parser: 'glimmer',\n  singleQuote: true\n});\n\nconsole.log(formatted);\n// Output:\n// <div>\n//   {{#if condition}}\n//     <span>{{name}}</span>\n//   {{/if}}\n// </div>","lang":"typescript","description":"Formats a Handlebars template using the glimmer parser with single quotes option. Uses ESM import syntax."},"warnings":[{"fix":"Switch to ESM imports (import ... from 'prettier-hbs') or use dynamic import().","message":"prettier-hbs v3 is ESM-only and no longer supports CommonJS (require()).","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Configure prettier-hbs overrides in your .prettierrc: { \"overrides\": [{ \"files\": \"*.hbs\", \"options\": { \"parser\": \"glimmer\" } }] }","message":"The 'parser' option must be set to 'glimmer' for Handlebars files. Using the default 'babel' or 'html' parser will produce incorrect output.","severity":"deprecated","affected_versions":"*"},{"fix":"Refer to Prettier v2 documentation for supported options. Do not expect Prettier v3 features.","message":"prettier-hbs is a fork based on Prettier v2.8.8. Options and behavior from later Prettier versions (e.g., v3) are not available.","severity":"gotcha","affected_versions":"*"},{"fix":"If you need double quotes in expressions, this fork may not suit your project. Consider upstream Prettier or another tool.","message":"The package forces single quotes in Handlebars expressions (e.g., {{t 'something'}}) regardless of the singleQuote option for other languages.","severity":"gotcha","affected_versions":"*"},{"fix":"If you need no trailing newline or multiple newlines, post-process the output.","message":"Trailing newline at end of file is always forced to a single \\n, not configurable.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'14':42 '2023':75 '3.1.7':39 'accept':66 'attribut':16 'base':9 'block':17,21 'cadenc':69 'close':29 'condit':15 'current':37 'esm':49 'exclus':48 'express':36 'fix':14,64 'forc':32 'fork':5,55 'format':13,63 'handlebar':12,57 'hbs':3,62 'irregular':71 'javascript':76 'june':74 'last':72 'line':20 'need':60 'node':41 'offici':52 'one':19 'one-lin':18 'partial':22 'patch':11 'prettier':2,7,53 'prettier-hb':1 'project':58 'quot':34 'releas':68 'self':28 'self-clos':27 'ship':43 'singl':33 'slash':25 'specif':61 'support':40 'syntax':23 'tag':30 'target':56 'trail':24 'type':45 'typescript':44,77 'unlik':50 'updat':73 'upstream':67 'v2.8.8':8 'version':38","created_at":"2026-06-04T18:54:00.939659+00:00","updated_at":"2026-06-04T18:54:00.939659+00:00","problems":[{"fix":"Run `npm install prettier-hbs` and use ESM import: `import { format } from 'prettier-hbs';`","cause":"Package not installed or wrong import syntax.","error":"Cannot find module 'prettier-hbs'"},{"fix":"Switch to ESM: set `\"type\": \"module\"` in package.json or use dynamic import: `const prettier = await import('prettier-hbs');`","cause":"Using CommonJS require() with an ESM-only package (v3+).","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Use named import: `import { format } from 'prettier-hbs';`","cause":"Default import used incorrectly; format is a named export.","error":"TypeError: prettier.format is not a function"},{"fix":"Add to .prettierrc: `{ \"overrides\": [{ \"files\": \"*.hbs\", \"options\": { \"parser\": \"glimmer\" } }] }`","cause":"No parser specified in config or override for .hbs files.","error":"Error: No parser could be inferred for file"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://prettier.io","github":"https://github.com/falsefalse/prettier-hbs","docs":null,"changelog":null,"pypi":null,"npm":"prettier-hbs","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}