Extracts Ruby code from view templates (ERB, etc.) for Sorbet type-checking, with LSP support
open sourceMITself-hostablefree
sorbet_view is a Ruby gem that type-checks the Ruby inside Rails ERB templates with Sorbet: it parses templates with Herb, writes typed Ruby files with a source map back to each template, and runs srb tc over them, so errors point at the right line of the .erb file. It also runs as a language server proxy, giving hover, completion and go-to-definition inside .erb files through its VS Code extension, and recompiles a controller's templates when the controller is saved. Partial locals are typed with locals and locals_sig magic comments, ViewComponent erb_template heredocs are compiled too, and a Tapioca DSL compiler writes RBIs for helper methods and infers instance variable types from controller actions using srb_lens. It is a young one-developer project: its first release was in March 2026 and its latest (0.20.0) in July 2026.
Problems it solves
- Sorbet ignores the Ruby code in our Rails ERB views, so view bugs only show up at runtime
- get hover, autocomplete and go-to-definition for Ruby inside .erb files in VS Code
- type errors from view templates should point at the template line, not at generated code
- know the types of controller instance variables when type-checking the view that renders them
- type-check ViewComponent templates written as erb_template heredocs
- declare typed locals for Rails partials and get an error when a caller passes the wrong type
- run one command in CI that compiles our view templates and type-checks them
Features
- compiles ERB templates to typed Ruby files and type-checks them with Sorbet (sv tc)
- source maps between templates and generated Ruby for error locations in the template
- LSP proxy server with hover, completion and go-to-definition in .erb files
- VS Code extension
- recompiles a controller's templates when the controller file is saved
- locals and locals_sig magic comments for typed partial locals
- ViewComponent erb_template heredoc support
- Tapioca DSL compiler for helper method RBIs and controller instance variable types (via srb_lens)
- uses Herb for fast ERB parsing
- YAML configuration: input and component directories, typed level, Sorbet options
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Has official SDKs | plan not known |
Alternatives
The same job
These do what sorbet_view does.
- sorbet_erb Extracts Ruby code from ERB files so you can run Sorbet over them
- Sorbet for Rails A Sorbet build for Rails apps that type-checks specs, factories, and ERB views
