Registry / devops / prettier-plugin-hbs

prettier-plugin-hbs

JSON →
library1.0.1jsnpmunverified

A Prettier plugin that adds support for formatting Handlebars templates, primarily used in Ember.js applications. Current stable version 1.0.1. Development appears to be minimal with infrequent updates. Differentiates from other Handlebars formatters by integrating directly with Prettier, leveraging its consistent formatting engine and configuration. Suitable for Ember.js projects using GJS/GTS files or standalone .hbs templates.

npm install prettier-plugin-hbs
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-HB
P
prettier-plugin-hbs
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

prettier-plugin-hbs
// In .prettierrc: { "plugins": ["prettier-plugin-hbs"] } or Prettier API: const prettier = require('prettier'); prettier.format(code, { parser: 'hbs', plugins: [require('prettier-plugin-hbs')] });
import plugin from 'prettier-plugin-hbs'; (not used directly; plugin is used via Prettier configuration)
Plugin is not imported directly in code; it's registered in Prettier config or passed as an option.
hbs
const formatted = prettier.format(template, { parser: 'hbs', plugins: [require('prettier-plugin-hbs')] });
const formatted = prettier.format(template, { parser: 'handlebars' }); (wrong parser name)
Parser ID is 'hbs', not 'handlebars'.

Install Prettier and the plugin, configure with .prettierrc, then format a .hbs file.

npm install --save-dev prettier prettier-plugin-hbs # Then create .prettierrc: echo '{ "plugins": ["prettier-plugin-hbs"] }' > .prettierrc # Format a file: npx prettier --write app/templates/application.hbs
Debug
Known issues
gotchaPlugin must be installed as a devDependency alongside Prettier.
fix
Ensure prettier is also installed: npm install --save-dev prettier
affects: >=0.0.1
deprecatedVersion 1.0.1 may not support the latest Prettier versions (e.g., 3.x).
fix
Check plugin compatibility; consider alternative plugins like 'prettier-plugin-ember-template-tag' for Ember GJS/GTS files.
affects: >=3.0.0
gotchaParser name is 'hbs', not 'handlebars' as one might expect.
fix
Use parser: 'hbs' in Prettier configuration or API calls.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-hbs'
Plugin not installed or not in node_modules.
fix
Run npm install --save-dev prettier-plugin-hbs
Couldn't resolve parser "hbs"
Plugin is not specified in Prettier plugins list.
fix
Add 'plugins': ['prettier-plugin-hbs'] to .prettierrc or pass plugins option in API.
Error: Plugin prettier-plugin-hbs requires Prettier 2.x
Incompatible Prettier version (e.g., 3.x).
fix
Downgrade Prettier to 2.x or use a compatible plugin.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
prettierrequiredPeer dependency; requires Prettier as the formatting engine.
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-hbs — npm install prettier-plugin-hbs · libregistry