SlimX
A from-scratch Slim engine for Rails: no Temple, a single-pass compiler, and a formatter and a linter that read templates with the same parser.
gem "slimx"
In numbers
Loading the latest numbers…
Same HTML
SlimX renders what Slim 5 renders with format: :html, sort_attrs: false, down to the byte. Here is the benchmark page, rendered by both engines:
……Identical on 295 of Slim’s own tests, on the 1,400 templates of a production app, and on 10,000 new random templates at every CI run.
In the box
An engine for Rails and Tilt
A railtie registers .slim with Action View; require "slimx/tilt" serves Sinatra, Hanami and Roda. Every - and = stays on its template line, so backtraces point at the right one.
A formatter that cannot change a page
slimx fmt writes one layout, and compiles both versions before writing: if the Ruby differs, it refuses.
Strict mode
An unformatted template fails to compile, pointing at the first line and what it should be. gofmt discipline, at compile time.
A linter with HTML and accessibility rules
Rules from slim-lint, haml-lint, erb_lint, Herb and jsx-a11y, each with a flagged and a clean example.
Tailwind class names
One option, and .rounded-b-[3px], .size-2.5 or .lg:hover:underline work as class shortcuts. Attribute lists keep their meaning.
Nothing new to learn
The whole Slim 5 grammar, the same HTML, the same errors. What SlimX leaves out fails at compile time instead of rendering wrong. The grammar is Slim’s, by the Slim Team.
Quick start
Gemfile
gem "slimx" # instead of slim-rails
Terminal
bundle exec slimx fmt # once
bundle exec slimx lint # in CI
bundle exec slimx fmt --check # in CI