@poliklot/prettier-plugin-handlebars weekly downloads statistics
By poliklot (3 listings) · npm · Prettier plugins
Prettier plugin for classic Handlebars (.hbs)
@poliklot/prettier-plugin-handlebars has 1,315 recorded weekly downloads on npm, a decrease of 63.0% over the past 30 days, ranking #2002 of 3,247 tracked listings.
About @poliklot/prettier-plugin-handlebars
@poliklot/prettier-plugin-handlebars
Prettier plugin for classic Handlebars templates with mixed HTML markup.
It formats .hbs / .handlebars files used in HTML-heavy Handlebars projects,
with a focus on stable, idempotent output and preserving classic Handlebars
semantics.
Install
npm install --save-dev prettier @poliklot/prettier-plugin-handlebars
Quick Start
Recommended config:
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["@poliklot/prettier-plugin-handlebars"],
overrides: [
{
files: ["*.hbs", "*.handlebars"],
options: {
parser: "handlebars",
},
},
],
};
The explicit override keeps .hbs files on this plugin even in Prettier versions that also know about other Handlebars-like parsers.
Configuration Patterns
1. Minimal plugin setup
Use this only when you have verified that your Prettier version and editor resolve .hbs files to this plugin. The explicit override below is safer for shared projects.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["@poliklot/prettier-plugin-handlebars"],
};
2. Explicit Handlebars override
Use this when you want stable format-on-save behavior in editors, or when your project mixes multiple template types.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["@poliklot/prettier-plugin-handlebars"],
overrides: [
{
files: ["*.hbs", "*.handlebars"],
options: {
parser: "handlebars",
},
},
],
};
3. Explicit Handlebars override with project style
Normal Prettier options still work and often matter a lot for .hbs.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["@poliklot/prettier-plugin-handlebars"],
overrides: [
{
files: ["*.hbs", "*.handlebars"],
options: {
parser: "handlebars",
printWidth: 120,
useTabs: true,
tabWidth: 4,
singleQuote: true,
htmlWhitespaceSensitivity: "ignore",
},
},
],
};
4. Local plugin path during dogfooding
Useful when you are testing the plugin from a neighboring repository before publishing a new npm version.
/** @type {import("prettier").Config} */
module.exports = {
plugins: ["../prettier-plugin-handlebars/dist/plugin.js"],
overrides: [
{
files: ["*.hbs", "*.handlebars"],
options: {
parser: "handlebars",
},
},
],
};
5. JSON config
{
"plugins": ["@poliklot/prettier-plugin-handlebars"],
"overrides": [
{
"files": ["*.hbs", "*.handlebars"],
"options": {
"parser": "handlebars",
"printWidth": 120,
"useTabs": true,
"tabWidth": 4
}
}
]
}
CLI
Published package:
npx prettier --write "src/**/*.{hbs,handlebars}" --plugin @poliklot/prettier-plugin-handlebars --parser handlebars
Local plugin build:
npx prettier --write "src/**/*.{hbs,handlebars}" --plugin ../prettier-plugin-handlebars/dist/plugin.js --parser handlebars
Project Setup Audit
The package also ships a small setup helper:
npx @poliklot/prettier-plugin-handlebars init
By default this is a dry run. It reports whether the project has:
- local
prettierand@poliklot/prettier-plugin-handlebarsdependencies; - a Prettier config that loads the plugin;
- an explicit
*.hbs/*.handlebarsoverride withparser: "handlebars"; .prettierignorepatterns that skip Handlebars files.
Apply supported JSON config changes with:
npx @poliklot/prettier-plugin-handlebars init --write
Use it in CI or local checks with:
npx @poliklot/prettier-plugin-handlebars init --check
The helper can create or update .prettierrc, .prettierrc.json, and the prettier object in package.json. JavaScript, JSON5, YAML, and TOML configs are detected but not rewritten automatically; the command prints the manual action instead.
API
const prettier = require("prettier");
const plugin = require("@poliklot/prettier-plugin-handlebars");
async function run(source) {
return prettier.format(source, {
filepath: "template.hbs",
parser: "handlebars",
plugins: [plugin],
});
}
Plugin Options
dataAttributeOrder
Custom ordering override for data-* attributes.
| Default | CLI Override | API Override |
|---|---|---|
[] | --data-attribute-order <value> | dataAttributeOrder: string[] |
{
"plugins": ["@poliklot/prettier-plugin-handlebars"],
"dataAttributeOrder": ["data-testid", "data-state", "data-track"]
}
maxEmptyLines
Maximum number of consecutive blank lines preserved between nodes.
| Default | CLI Override | API Override |
|---|---|---|
1 | --max-empty-lines <int> | maxEmptyLines: number |
{
"plugins": ["@poliklot/prettier-plugin-handlebars"],
"maxEmptyLines": 1
}
classAttributeSameLine
Keep the first and last tokens of multiline conditional class attributes glued to their surrounding quotes.
| Default | CLI Override | API Override |
|---|---|---|
false | --class-attribute-same-line | classAttributeSameLine: boolean |
{
"plugins": ["@poliklot/prettier-plugin-handlebars"],
"classAttributeSameLine": true
}
classAttributeLayout
Control whether class attribute values may use multiple physical lines. The default auto mode preserves the existing formatting rules. Use single-line to keep static and conditional class values on one line; the surrounding HTML tag may still wrap.
| Default | CLI Override | API Override |
|---|---|---|
"auto" | --class-attribute-layout <auto|single-line> | classAttributeLayout: "auto" | "single-line" |
Description from the npm listing.
- prettier
- prettier-plugin
- handlebars
- hbs
- html
- formatter
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Prettier plugins plugins
All 20 @poliklot/prettier-plugin-handlebars alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@poliklot/prettier-plugin-handlebars. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.