Linux "erb" Command Line Options and Examples
Ruby Templating

erb is a command line front-end for ERB library, which is an implementation of eRuby. ERB provides an easy to use but powerful templating system for Ruby. Using ERB, actual Ruby code can be added to any plain text docu‐ ment for the purposes of generating document information details and/or flow control.


erb [--version] [-UPdnvx] [-E ext[:int]] [-S level] [-T mode] [-r library] [--] [file ...]

Command Line Options:

Prints the version of erb.
erb --version ...
erb -E ...
Specifies the default value(s) for external encodings and internal encoding. Values should be separated with colon (:).You can omit the one for internal encodings, then the value (Encoding.default_internal) will be nil.
erb --encoding ...
Evaluates lines starting with % as Ruby code and removes the tailing EOLs.
erb -P ...
level Specifies the safe level in which eRuby script will run.
erb -S ...
0 EOL remains after the embedded ruby script is evaluated.1 EOL is removed if the line ends with %>.2 EOL is removed if the line starts with <% and ends with %>.
erb -T ...
can be one of Sets the default value for internal encodings (Encoding.default_internal) to UTF-8.
erb -U ...
Turns on debug mode. $DEBUG will be set to true.
erb --debug ...
Prints a summary of the options.
erb --help ...
Used with -x. Prepends the line number to each line in the output.
erb -n ...
Enables verbose mode. $VERBOSE will be set to true.
erb -v ...
EXAMPLESHere is an eRuby script<?xml version="1.0" ?><% require 'prime' -%><erb-example><calc><%= 1+1 %></calc><var><%= __FILE__ %></var><library><%= Prime.each(10).to_a.join(", ") %></library></erb-example>Command% erb -T - example.erbprints<?xml version="1.0" ?><erb-example><calc>2</calc><var>example.erb</var><library>2, 3, 5, 7</library></erb-example>
erb -x ...