A prettier plugin for html erb template files that works with prettier v3.
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
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.
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
This plugin doesn't have any special config. You can configure the ruby formatting using the options of @prettier/plugin-ruby.
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.
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
@davidodenwald for his plugin prettier-plugin-jinja-template which served as a base for this plugin.