A prettier plugin for html erb template files that works with prettier v3.
This library probably won't be developed any further because I no longer work with Ruby on Rails and thus, the ERB templating system. Feel free to make PRs, fork or whatever you want with this library.
npm install --save-dev prettier @4az/prettier-plugin-html-erb @prettier/plugin-rubyyarn add -D prettier @4az/prettier-plugin-html-erb @prettier/plugin-rubypnpm install --save-dev prettier @4az/prettier-plugin-html-erb @prettier/plugin-rubyIf you want to install the dependencies globally:
gem install bundler prettier_print syntax_treeOr 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.rbThis 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.