Registry / devops / prettier-html-templates

prettier-html-templates

JSON →
library0.1.0jsnpmunverified

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.

npm install prettier-html-templates
INSTALL
IMPORT
SIG · PRETTIER-HTML-TEMP
P
prettier-html-templates
devopsjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import prettierPluginHtmlTemplates from 'prettier-html-templates'
const prettierPluginHtmlTemplates = require('prettier-html-templates')
ESM-only; no CommonJS export. Works only with Prettier 2.x.
getFormattedHtml
import { getFormattedHtml } from 'prettier-html-templates'
const { getFormattedHtml } = require('prettier-html-templates')
Internal utility, not intended for public use. Exported for plugin authors.
PRINTER
import { PRINTER } from 'prettier-html-templates'
Prettier printer object used in plugin definitions.

Shows how to use the plugin with Prettier to format HTML containing template syntax.

import prettier from 'prettier'; import prettierPluginHtmlTemplates from 'prettier-html-templates'; const code = '<div class="<% if (condition) { %>active<% } %>">Content</div>'; const options = { parser: 'html', plugins: [prettierPluginHtmlTemplates], printWidth: 80 }; const formatted = await prettier.format(code, options); console.log(formatted);
Debug
Known issues
gotchaclass attributes are not formatted by this package.
fix
Manually format class attributes or wait for a future release.
affects: 0.1.0
gotchastyle attributes are not formatted by this package.
fix
Manually format style attributes or wait for a future release.
affects: 0.1.0
gotchaprettier ignore comments do not work with this plugin.
fix
Use alternative mechanisms to exclude code from formatting.
affects: 0.1.0
breakingRequires Prettier v2.x; incompatible with Prettier v3.
fix
Use Prettier v2.x for this plugin version.
affects: 0.1.0
Errors
Common errors & fixes
Error: Could not find plugin: prettier-html-templates
Plugin not installed or not added to plugins array in Prettier config.
fix
npm install prettier-html-templates --save-dev and add it to plugins: ['prettier-html-templates']
TypeError: prettier.format is not a function
Using CommonJS require on an ESM-only module.
fix
Use import instead of require, or set "type": "module" in package.json.
SyntaxError: Unexpected token '<' in JSON at position 0
Plugin returns unformatted HTML; usually due to unsupported template syntax causing parser to fallback to markup.
fix
Ensure your template syntax is supported; check the plugin's GitHub issues.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
prettierrequiredRuntime peer dependency for plugin integration
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-html-templates — npm install prettier-html-templates · libregistry