prettier-plugin-handlebars

raw JSON →
0.0.1 verified Sat Apr 25 auth: no javascript

Prettier plugin for formatting Handlebars templates, including partials support. Version 0.0.1 is the initial release. It is a lightweight plugin that integrates with Prettier to format Handlebars files using the prettier/handlebars parser. Key differentiators include support for partials, custom delimiters, and seamless integration with Prettier's existing workflows.

error Cannot find module 'prettier-plugin-handlebars'
cause Plugin not installed or not in node_modules.
fix
Run 'npm install prettier-plugin-handlebars'
error Error: Couldn't resolve parser "handlebars"
cause Plugin not specified in Prettier config plugins array.
fix
Add '"plugins": ["prettier-plugin-handlebars"]' to .prettierrc
error TypeError: prettier-plugin-handlebars is not a plugin
cause Using CommonJS require with ESM-only plugin.
fix
Use import syntax or dynamic import() in Prettier config.
breaking Plugin requires Prettier v3 or later due to ESM-only exports.
fix Upgrade Prettier to v3+.
gotcha Handlebars expressions inside HTML attributes may not be formatted correctly.
fix Use alternative formatting or manual review for complex attribute expressions.
deprecated Custom delimiters are not supported in this version.
fix Only use default {{ }} delimiters.
npm install prettier-plugin-handlebars
yarn add prettier-plugin-handlebars
pnpm add prettier-plugin-handlebars

Configures Prettier to format .hbs files using the Handlebars plugin.

// .prettierrc
{
  "plugins": ["prettier-plugin-handlebars"],
  "overrides": [
    {
      "files": "*.hbs",
      "options": {
        "parser": "handlebars"
      }
    }
  ]
}