1ERB(1) Ruby Programmer's Reference Guide ERB(1)
2
4 erb — Ruby Templating
5
7 erb [--version] [-UPdnvx] [-E ext[:int]] [-S level] [-T mode]
8 [-r library] [--] [file ...]
9
11 erb is a command line front-end for ERB library, which is an implementa‐
12 tion of eRuby.
13
14 ERB provides an easy to use but powerful templating system for Ruby.
15 Using ERB, actual Ruby code can be added to any plain text document for
16 the purposes of generating document information details and/or flow con‐
17 trol.
18
19 erb is a part of Ruby.
20
22 --version Prints the version of erb.
23
24 -E external[:internal]
25 --encoding external[:internal]
26 Specifies the default value(s) for external encodings and
27 internal encoding. Values should be separated with colon
28 (:).
29
30 You can omit the one for internal encodings, then the
31 value (Encoding.default_internal) will be nil.
32
33 -P Evaluates lines starting with % as Ruby code and removes
34 the tailing EOLs.
35
36 -S level Specifies the safe level in which eRuby script will run.
37
38 -T mode Specifies trim mode (default 0). mode can be one of
39
40 0 EOL remains after the embedded ruby script
41 is evaluated.
42
43 1 EOL is removed if the line ends with %>.
44
45 2 EOL is removed if the line starts with <%
46 and ends with %>.
47
48 - EOL is removed if the line ends with -%>.
49 And leading whitespaces are removed if the
50 erb directive starts with <%-.
51
52 -r Load a library
53
54 -U can be one of Sets the default value for internal encod‐
55 ings (Encoding.default_internal) to UTF-8.
56
57 -d
58 --debug Turns on debug mode. $DEBUG will be set to true.
59
60 -h
61 --help Prints a summary of the options.
62
63 -n Used with -x. Prepends the line number to each line in
64 the output.
65
66 -v Enables verbose mode. $VERBOSE will be set to true.
67
68 -x Converts the eRuby script into Ruby script and prints it
69 without line numbers.
70
72 Here is an eRuby script
73
74 <?xml version="1.0" ?>
75 <% require 'prime' -%>
76 <erb-example>
77 <calc><%= 1+1 %></calc>
78 <var><%= __FILE__ %></var>
79 <library><%= Prime.each(10).to_a.join(", ") %></library>
80 </erb-example>
81
82 Command
83 % erb -T - example.erb
84 prints
85
86 <?xml version="1.0" ?>
87 <erb-example>
88 <calc>2</calc>
89 <var>example.erb</var>
90 <library>2, 3, 5, 7</library>
91 </erb-example>
92
94 ruby(1).
95
96 And see ri(1) documentation for ERB class.
97
99 · Security vulnerabilities should be reported via an email to
100 security@ruby-lang.org. Reported problems will be published after
101 being fixed.
102
103 · Other bugs and feature requests can be reported via the Ruby Issue
104 Tracking System (https://bugs.ruby-lang.org/). Do not report secu‐
105 rity vulnerabilities via this system because it publishes the vulner‐
106 abilities immediately.
107
109 Written by Masatoshi SEKI.
110
111UNIX November 15, 2012 UNIX