@4az/prettier-plugin-html-erb

中文文档
0.0.7发布于 2025/06/14MITES Module零依赖近 30 天下载 1.6万

Prettier plugin for formatting html erb templates.

原始使用文档

@4az/prettier-plugin-html-erb

A prettier plugin for html erb template files that works with prettier v3.

Install

Node

npm install --save-dev prettier @4az/prettier-plugin-html-erb @prettier/plugin-ruby
yarn add -D prettier @4az/prettier-plugin-html-erb @prettier/plugin-ruby
pnpm install --save-dev prettier @4az/prettier-plugin-html-erb @prettier/plugin-ruby

Ruby

If you want to install the dependencies globally:

gem install bundler prettier_print syntax_tree

Or if you are using bundler:

bundler add prettier_print syntax_tree --group="development"

If you're having problems, check the repository of @prettier/plugin-ruby.

Use

Add the plugins to your .prettierrc:

{
    "plugins": ["@prettier/plugin-ruby", "@4az/prettier-plugin-html-erb"]
}

If any file doesn't format, check the output running prettier in the terminal:

npx prettier ./src/myfile.html.rb

Configuration

This plugin doesn't have any special config. You can configure the ruby formatting using the options of @prettier/plugin-ruby.

Roadmap

There are a number of features I want to support:

  • Support erb delimiters. Ex: <%- delimiters -%>.
  • Port library to TypeSript.
  • Add a way to ignore sections of code of being formatted.
  • Support more ways to format blocks.

Testing

To run tests:

git clone https://github.com/ForAzens/prettier-plugin-html-erb.git
cd prettier-plugin-html-erb
npm install
gem install bundler prettier_print syntax_tree
npm run test

Special thanks

@davidodenwald for his plugin prettier-plugin-jinja-template which served as a base for this plugin.

License

MIT

版本与发布记录

@4az/prettier-plugin-html-erb 共发布 7 个版本,首次发布于 2024/11/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.7latest2025/06/141.4 年前
0.0.62024/11/082 年前
0.0.52024/11/082 年前
0.0.42024/11/062 年前
0.0.32024/11/052 年前
0.0.22024/11/052 年前

关于 @4az/prettier-plugin-html-erb 的常见问题

@4az/prettier-plugin-html-erb 是什么?

Prettier plugin for formatting html erb templates.

如何安装 @4az/prettier-plugin-html-erb?

在项目目录运行 npm install @4az/prettier-plugin-html-erb,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@prettier/plugin-ruby(^4.0.0)、prettier(^3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@4az/prettier-plugin-html-erb 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/4az__prettier-plugin-html-erb 是否存在。

@4az/prettier-plugin-html-erb 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@4az/prettier-plugin-html-erb 可以商用吗?

@4az/prettier-plugin-html-erb 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@4az/prettier-plugin-html-erb 的下载量有多少?

根据 npm 官方下载统计,@4az/prettier-plugin-html-erb 在 2026/10/05 – 2026/11/03 这 30 天内被下载 15,846 次,日均约 528 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@4az/prettier-plugin-html-erb 还在维护吗?

最新版本 0.0.7 发布于 2025/06/14(1.4 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/11/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。