Registry / web-framework / prettier-plugin-erb

prettier-plugin-erb

JSON →
library0.4.0jsnpmunverified

A Prettier plugin for formatting .html.erb files, currently at version 0.4.0. It integrates with Prettier (>=2.0.0 <2.3) and depends on @prettier/plugin-ruby for formatting multiline Ruby expressions. Key differentiators: allows ERB formatting within Prettier's ecosystem, supports single-line expressions, and includes basic comment handling. The plugin is relatively new with limited features (no block expression formatting yet) and may have bugs; users are encouraged to ignore problematic files via .prettierignore.

npm install prettier-plugin-erb
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-ER
P
prettier-plugin-erb
web-frameworkjavascriptv0.4.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.

prettier-plugin-erb
Add to .prettierrc: { "plugins": ["prettier-plugin-erb"] }
Using `require('prettier-plugin-erb')` in code
This is a Prettier plugin, not a programmatic library; it's configured via .prettierrc or CLI.
default
Not applicable; no programmatic export.
Importing as `import erb from 'prettier-plugin-erb'`
No JS exports; the plugin is loaded by Prettier via plugins configuration.
N/A
Not applicable
Using `@prettier/plugin-ruby` instead of `prettier-plugin-erb` for ERB files
The plugin requires both `@prettier/plugin-ruby` and `prettier-plugin-erb` in plugins list.

Shows installation, configuration in .prettierrc, and CLI usage for formatting .html.erb files.

// Install dependencies // yarn add -D prettier@2.2.0 @prettier/plugin-ruby@1.0.0 prettier-plugin-erb@0.4.0 // .prettierrc { "plugins": [ "@prettier/plugin-ruby", "prettier-plugin-erb" ], "tabWidth": 2 } // Run // npx prettier --write app/views/**/*.html.erb
Debug
Known issues
breakingThe plugin requires Prettier <2.3 due to compatibility issues with Prettier options.
fix
Use Prettier version 2.2.x or lower. Check peerDependencies: prettier >=2.0.0 <2.3.
affects: >=0.1.0
gotchaBlock expressions (e.g., <% if … %> … <% end %>) are not formatted; only single-line expressions work.
fix
Upgrade to v0.2.0+ for single-line expressions; block expressions still not supported in any version.
affects: <0.2.0
gotchaThe plugin may return `[object Object]` as output in edge cases (fixed in v0.4.0).
fix
Upgrade to v0.4.0 or later.
affects: <0.4.0
deprecatedThe `print` function replaces `embed` for error logging (v0.2.0+).
fix
Upgrade to v0.2.0+ if you rely on error formatting.
affects: <0.2.0
gotchaThe plugin may format files incorrectly; add problematic files to .prettierignore.
fix
Use .prettierignore to exclude files that cause errors or unwanted formatting.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: Unexpected token '>'
Prettier version >=2.3 is incompatible with this plugin.
fix
Downgrade Prettier to version 2.2.x or lower.
Error: Cannot find module '@prettier/plugin-ruby'
Missing peer dependency @prettier/plugin-ruby.
fix
Install the missing peer: `yarn add -D @prettier/plugin-ruby`
Error: [object Object]
Bug in older versions (<0.4.0) when formatting certain ERB expressions.
fix
Upgrade to version 0.4.0 or later.
Cannot read property 'type' of undefined
Block expressions (e.g., <% if %>) not supported; the plugin cannot parse them.
fix
Remove or rewrite block expressions as single-line ERB, or add file to .prettierignore.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
prettierrequiredpeer dependency for formatting engine
@prettier/plugin-rubyrequiredpeer dependency for formatting multiline Ruby expressions
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-plugin-erb — npm install prettier-plugin-erb · libregistry