A modern templating language for the HTML+ERB you already have.
open sourceMITself-hostablefree
Herb reads the HTML and the Ruby in .html.erb templates as one document, using a fast HTML-aware ERB parser written in C (with Prism for the Ruby) and bindings for Ruby, JavaScript, Java, Rust and WebAssembly. On top of it sit a linter for HTML, ERB, accessibility and Action View conventions, an experimental formatter, a language server for VS Code, Zed, Neovim, RubyMine and other editors, a dev server and browser dev tools. Herb::Engine renders templates the way Erubi does, escaping each value for where it sits in the HTML; the README says the Rails 8.2 framework defaults render HTML templates with it.
Problems it solves
- lint my Rails ERB views for unclosed tags and mismatched elements before they reach production
- a missing %> in a view only shows up as a confusing error when the page renders
- format .html.erb files consistently across the team
- get diagnostics and formatting for ERB templates in VS Code or Neovim
- catch accessibility mistakes like missing alt text in server-rendered Rails templates
- parse ERB templates into a syntax tree so I can build my own tooling or codemods
- check ERB views in CI without adding a dependency to the project
- render ERB templates with HTML-context-aware escaping instead of plain Erubi
- see the page update in the browser as soon as I save a Rails view
- enforce Action View helper conventions in templates
- erb_lint is slow and doesn't really understand the HTML structure
Features
- HTML-aware ERB parser in C with Prism
- bindings for Ruby, JavaScript, Java, Rust and WebAssembly
- linter (HTML, ERB, accessibility, Action View rules)
- formatter (experimental)
- language server for VS Code, Zed, Neovim, RubyMine, Helix, Sublime Text and others
- Herb::Engine, Erubi-compatible rendering with context-aware escaping
- dev server (experimental)
- in-browser dev tools
- browser playground
- gem exec herb analyze with no install
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Has official SDKs | plan not known |
