{"id":13878621,"url":"https://github.com/nebulab/erb-formatter","last_synced_at":"2025-05-15T09:08:27.462Z","repository":{"id":40480328,"uuid":"468790080","full_name":"nebulab/erb-formatter","owner":"nebulab","description":"Format ERB files with speed and precision","archived":false,"fork":false,"pushed_at":"2025-04-07T10:23:33.000Z","size":169,"stargazers_count":165,"open_issues_count":26,"forks_count":28,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T06:39:13.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nebulab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-11T14:50:54.000Z","updated_at":"2025-04-07T10:23:38.000Z","dependencies_parsed_at":"2023-02-18T09:30:49.548Z","dependency_job_id":"17164ae9-b93f-4616-a6ad-0e4939589a4a","html_url":"https://github.com/nebulab/erb-formatter","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":"0.14893617021276595","last_synced_commit":"6581ff405ee365c17f73c39869d2cf3705c5b3f5"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Ferb-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Ferb-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Ferb-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Ferb-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nebulab","download_url":"https://codeload.github.com/nebulab/erb-formatter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310520,"owners_count":22049470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:54.975Z","updated_at":"2025-05-15T09:08:22.454Z","avatar_url":"https://github.com/nebulab.png","language":"Ruby","funding_links":[],"categories":["Ruby","Programming Languages"],"sub_categories":[],"readme":"# ERB::Formatter 🪜\n\nFormat ERB files with speed and precision.\n\nFeatures:\n\n- very fast\n- attempts to limit length (configurable)\n- tries to have an output similar to prettier for HTML\n- indents correctly ruby blocks (e.g. `if`/`elsif`/`do`/`end`)\n- designed to be integrated into editors and commit hooks\n- gives meaningful output in case of errors (most of the time)\n- will use multiline values for `class` and `data-action` attributes\n\nRoadmap:\n\n- extensive unit testing\n- more configuration options\n- more ruby reformatting capabilities\n- JavaScript and CSS formatting\n- VSCode plugin\n- fix spaces after attribute equal signs instead of complaining\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    $ bundle add erb-formatter\n\nOr install it yourself as:\n\n    $ gem install erb-formatter\n\n## Usage\n\n### From [Visual Studio Code](https://code.visualstudio.com)\n\nJust install the [Ruby ERB::Formatter 🪜](https://marketplace.visualstudio.com/items?itemName=elia.erb-formatter) extension\nand follow the setup instructions there.\n\n### From the command line\n\nUpdate files in-place:\n\n    $ erb-format app/views/**/*.html.erb --write\n\nor use stdin/stdout (useful for editor integrations):\n\n    $ echo \"\u003cdiv       \u003e asdf  \u003c% if 123%\u003e \u003c%='foobar'%\u003e \u003c%end-%\u003e  \u003c/div\u003e\" | erb-format --stdin\n    \u003cdiv\u003e\n      asdf\n      \u003c% if 123 %\u003e\n        \u003c%= 'foobar' %\u003e\n      \u003c% end -%\u003e\n    \u003c/div\u003e\n\nCheck out `erb-format --help` for more options.\n\n### From [Ruby](https://www.ruby-lang.org/en/)\n\n```ruby\nrequire 'erb/formatter'\n\nformatted = ERB::Formatter.format \u003c\u003c-ERB\n\u003cdiv        \u003e\n            asdf\n                  \u003c% if 123%\u003e\n                      \u003c%='foobar'%\u003e \u003c%end-%\u003e\n           \u003c/div\u003e\nERB\n\n# =\u003e \"\u003cdiv\u003e\\n  asdf\\n  \u003c% if 123 %\u003e\\n    \u003c%= 'foobar' %\u003e\\n  \u003c% end -%\u003e\\n\u003c/div\u003e\\n\"\n#\n# Same as:\n#\n#   \u003cdiv\u003e\n#     asdf\n#     \u003c% if 123 %\u003e\n#       \u003c%= 'foobar' %\u003e\n#     \u003c% end -%\u003e\n#   \u003c/div\u003e\n```\n\n### With [`lint-staged`](https://github.com/okonet/lint-staged#readme)\n\nAdd the gem to your gemfile and the following to your `package.json`:\n\n```js\n\"lint-staged\": {\n  // …\n  \"*.html.erb\": \"bundle exec erb-format --write\"\n}\n```\n\n### As a [TextMate](http://macromates.com) command\n\nCreate a command with the following settings:\n\n- **Scope selector:** `text.html.erb`\n- **Semantic class:** `callback.document.will-save`\n- **Input:** `document` → `text`\n- **Output:** `replace document` → `text`\n- **Caret placement:** `line-interpolation`\n\n```bash\n#!/usr/bin/env bash\n\ncd \"$TM_PROJECT_DIRECTORY\"\nbundle exec erb-format --stdin-filename \"$TM_FILEPATH\" \u003c /dev/stdin 2\u003e /dev/stdout\n```\n\n### With [(Neo)VIM ALE](https://github.com/dense-analysis/ale)\n\nEnable `erb-formatter` as a fixer in the ALE config:\n\n```vim\nlet g:ale_fixers = {\n\\   'eruby': ['erb-formatter'],\n\\}\n```\n\n### With Neovim [conform.nvim](https://github.com/stevearc/conform.nvim)\n\nSpecify `erb_format` as a formatter for the `eruby` filetype in the [Conform config](https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup):\n```lua\nformatters_by_ft = {\n  eruby = { \"erb_format\" },\n},\n```\n\n### With [Zed](https://zed.dev/) editor\n\nWith the gem installed, configure `settings.json` to use the formatter as an external command\n\n```json\n\"languages\": {\n  \"ERB\": {\n    \"formatter\": {\n      \"external\": {\n        \"command\": \"erb-format\",\n        \"arguments\": [\"--stdin\", \"--print-width\", \"80\"]\n      }\n    }\n  }\n}\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\nIn order to run a specific test, use the following command:\n\n```bash\nm test/erb/test_formatter.rb:123\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nebulab/erb-formatter.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebulab%2Ferb-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnebulab%2Ferb-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebulab%2Ferb-formatter/lists"}