Herb is a modern templating language for the HTML+ERB you already have.
Your .html.erb files are already HTML+ERB. Herb reads the HTML and the Ruby in them as one document, so it can tell you about an unclosed tag, a mismatched element or a missing %> with the file, the line and what to change, before the page renders. The same understanding drives a linter, a formatter, a language server for your editor and Herb::Engine, which renders your templates the way Erubi does and escapes each value for where it sits.
With the Rails 8.2 framework defaults, Rails renders HTML templates with Herb::Engine. ReActionView makes those templates reactive, and brings the error overlays, the dev tools and per-tag instrumentation to the page.
Check your templates without adding anything to your project:
gem exec herb analyzeAdd the gem:
bundle add herbRun the linter and the formatter:
npx @herb-tools/linter
npx @herb-tools/formatterInstallation covers editors, CI and installing from a Git branch.
| Project | Description |
|---|---|
| Herb Linter | Finds mistakes and enforces conventions in HTML+ERB templates. |
| Herb Formatter | Formats HTML+ERB templates consistently. (experimental) |
| Herb Language Server | Diagnostics, hovers and formatting in VS Code, Zed, Neovim and other editors. |
| Herb Dev Server | Watches your templates and patches the open page as you save. (experimental) |
| Herb Dev Tools | In-browser tools for inspecting and debugging rendered templates. |
| Project | Description |
|---|---|
Herb::Engine |
HTML-aware ERB rendering engine, API-compatible with Erubi. |
| Herb Client Runtime | Updates the parts of a rendered page that changed, in place. (experimental) |
| ReActionView | Reactive templates, error overlays and dev tools for Rails. |
The Herb Parser is a fast, portable, HTML-aware ERB parser written in C, with bindings for Ruby, JavaScript, Java, Rust and WebAssembly. The Projects page lists it together with the libraries for building your own tools on the Herb syntax tree.
Bug reports and pull requests are welcome on GitHub. CONTRIBUTING.md explains how to set up Herb for local development.
This project is available as open source under the terms of the MIT License.