{"id":20320,"library":"prettier-html-templates","title":"prettier-html-templates","description":"Library for building Prettier plugins to format HTML files containing template language markup such as Jinja, ERB, and others. Current stable version is 0.1.0. This package provides the infrastructure to embed template language constructs into Prettier's HTML formatting pipeline. It is the base for plugins like prettier-plugin-eex (Elixir) and prettier-plugin-erb (Ruby). Key differentiator: it enables unified formatting of mixed HTML/template files using Prettier's standard HTML printer, whereas alternatives often rely on language-specific formatters.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/adamzapasnik/prettier-html-templates","tags":["javascript","plugin","prettier"],"install":[{"cmd":"npm install prettier-html-templates","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-html-templates","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-html-templates","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency for plugin integration","package":"prettier","optional":false}],"imports":[{"note":"ESM-only; no CommonJS export. Works only with Prettier 2.x.","wrong":"const prettierPluginHtmlTemplates = require('prettier-html-templates')","symbol":"default","correct":"import prettierPluginHtmlTemplates from 'prettier-html-templates'"},{"note":"Internal utility, not intended for public use. Exported for plugin authors.","wrong":"const { getFormattedHtml } = require('prettier-html-templates')","symbol":"getFormattedHtml","correct":"import { getFormattedHtml } from 'prettier-html-templates'"},{"note":"Prettier printer object used in plugin definitions.","wrong":"","symbol":"PRINTER","correct":"import { PRINTER } from 'prettier-html-templates'"}],"quickstart":{"code":"import prettier from 'prettier';\nimport prettierPluginHtmlTemplates from 'prettier-html-templates';\n\nconst code = '<div class=\"<% if (condition) { %>active<% } %>\">Content</div>';\nconst options = {\n  parser: 'html',\n  plugins: [prettierPluginHtmlTemplates],\n  printWidth: 80\n};\n\nconst formatted = await prettier.format(code, options);\nconsole.log(formatted);","lang":"javascript","description":"Shows how to use the plugin with Prettier to format HTML containing template syntax."},"warnings":[{"fix":"Manually format class attributes or wait for a future release.","message":"class attributes are not formatted by this package.","severity":"gotcha","affected_versions":"0.1.0"},{"fix":"Manually format style attributes or wait for a future release.","message":"style attributes are not formatted by this package.","severity":"gotcha","affected_versions":"0.1.0"},{"fix":"Use alternative mechanisms to exclude code from formatting.","message":"prettier ignore comments do not work with this plugin.","severity":"gotcha","affected_versions":"0.1.0"},{"fix":"Use Prettier v2.x for this plugin version.","message":"Requires Prettier v2.x; incompatible with Prettier v3.","severity":"breaking","affected_versions":"0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install prettier-html-templates --save-dev and add it to plugins: ['prettier-html-templates']","cause":"Plugin not installed or not added to plugins array in Prettier config.","error":"Error: Could not find plugin: prettier-html-templates"},{"fix":"Use import instead of require, or set \"type\": \"module\" in package.json.","cause":"Using CommonJS require on an ESM-only module.","error":"TypeError: prettier.format is not a function"},{"fix":"Ensure your template syntax is supported; check the plugin's GitHub issues.","cause":"Plugin returns unformatted HTML; usually due to unsupported template syntax causing parser to fallback to markup.","error":"SyntaxError: Unexpected token '<' in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}