slim
Lightweight Ruby HTML template compiler
TLDR
Convert a Slim template to HTML
SYNOPSIS
slimrb [options] [inputfile_]
DESCRIPTION
slimrb is the command-line tool for the Slim template language. Slim is a lightweight Ruby templating engine that reduces HTML syntax to essential parts while maintaining readability. It uses indentation for nesting, eliminating the need for closing tags.
Slim syntax is concise: div.container becomes \<div class="container"\>, and h1= title outputs the value of title in an h1 tag. Attributes use parentheses: a(href=url) Link.
The tool can render templates to HTML, convert them to ERB for use in other contexts, or compile them to raw Ruby code for inspection. The --pretty option is useful for debugging, producing formatted HTML output.
Slim integrates with Rails, Sinatra, and any Rack-based framework through Tilt. It is one of the fastest Ruby template engines, comparable to Erubis in production mode.
PARAMETERS
-s, --stdin
Read input from standard input instead of a file-c, --compile
Compile template to Ruby code without executing-e, --erb
Convert Slim template to ERB format--rails
Generate Rails-compatible code (implies --compile)-p, --pretty
Output pretty-printed HTML with indentation-r, --require library
Load a Ruby library or Slim plugin before processing-o, --option name=code
Set Slim engine options-l, --locals Hash|YAML|JSON
Pass local variables to the template--trace
Show full traceback on errors-v, --version
Display version information-h, --help
Show help message
CAVEATS
Slim requires Ruby to be installed. Template syntax is whitespace-sensitive; mixing tabs and spaces can cause unexpected results. Some advanced Ruby expressions may need explicit output markers.
HISTORY
Slim was created by Andrew Stone, Fred Wu, and Daniel Mendler around 2010 as a cleaner alternative to ERB and Haml. The project aimed to provide minimal syntax while maintaining full Ruby integration. It uses the Temple framework for parsing and compilation.
