@@ -10,12 +10,10 @@ For a quick summary, type:
1010$ erb --help
1111```
1212
13- The format of the command is
14- ` erb [_options_] [_filepaths_] ` ,
15- where:
13+ The format of the command is ` erb [options] [filepaths] ` , where:
1614
1715- _ options_ are zero or more [ options] [ options ] .
18- - _ filepaths_ are zero or more paths to files, each containing an plain text
16+ - _ filepaths_ are zero or more paths to files, each containing plain text
1917 that can include \ERB tags.
2018
2119## Filepaths
@@ -27,10 +25,12 @@ that is, `erb` processes multiple files into a single result:
2725$ cat t.erb
2826< %= RUBY_VERSION %>
2927< %= Time.now %>
28+
3029$ cat u.erb
3130% Encoding.list.take(4).each do | encoding|
3231* < %= encoding %>
3332% end
33+
3434$ erb t.erb u.erb
35353.4.5
36362025-09-24 00:23:00 +0100
@@ -66,21 +66,22 @@ $ echo "<%= RUBY_VERSION %>" | erb # Prints the ERB version string.
6666Use option ` -d ` or ` --debug ` to turn on debugging output:
6767
6868``` bash
69- $ echo " <%= $DEBUG %>" | erb
70- " false"
71- $echo " <%= $DEBUG %>" | erb --debug
72- " true"
69+ $ echo " <%= \$ DEBUG %>" | erb
70+ false
71+
72+ $ echo " <%= \$ DEBUG %>" | erb --debug
73+ true
7374```
7475
7576### ` -E ` , ` --encoding ` : Set Encodings
7677
77- Use option ` -E ` or ` --encoding ` to set the default external encoding to ` _ex_ `
78- and, if ` _in_ ` is given, to set the default internal encoding to ` _in_ ` .
78+ Use option ` -E ex[:in] ` or ` --encoding ex[:in] ` to set the default external encoding to ` ex ` and,
79+ if ` in ` is given, to set the default internal encoding to ` in ` .
7980
8081Each encoding, ` ex ` and ` in ` , must be the name of an Encoding:
8182
82- ```
83- erb -E ASCII-8BIT:ASCII-8BIT t.erb
83+ ``` bash
84+ $ erb -E ASCII-8BIT:ASCII-8BIT t.erb
8485```
8586
8687### ` -h ` , ` --help ` : Print Help
@@ -100,6 +101,7 @@ with numbered lines:
100101$ cat t.erb
101102< %= RUBY_VERSION %>
102103< %= Time.now %>
104+
103105$ erb -n -x t.erb
104106 1 # coding:UTF-8
105107 2 _erbout = +' ' ; _erbout.<< (( RUBY_VERSION ).to_s); _erbout.<< "\n".freeze
@@ -119,11 +121,12 @@ $ erb -n t.erb
119121
120122By default, ` erb` enables [execution tag shorthand][execution tag shorthand]:
121123
122- ` ` `
124+ ` ` ` bash
123125$ cat u.erb
124126% Encoding.list.take(4).each do |encoding|
125127* <%= encoding %>
126128% end
129+
127130$ erb u.erb
128131* ASCII-8BIT
129132* UTF-8
@@ -133,7 +136,7 @@ $ erb u.erb
133136
134137You can use option ` -P` to disable the shorthand:
135138
136- ` ` `
139+ ` ` ` bash
137140$ erb -P u.erb # Raises NameError: "undefined local variable or method 'encoding'"
138141` ` `
139142
@@ -142,7 +145,7 @@ $ erb -P u.erb # Raises NameError: "undefined local variable or method 'encoding
142145You can use option ` -r` to load a library;
143146the option may be given multiple times, to load multiple libraries:
144147
145- ` ` `
148+ ` ` ` bash
146149$ erb -r csv -r bigdecimal t.erb
147150` ` `
148151
@@ -182,13 +185,14 @@ $ erb -U t.erb
182185Use option ` -v` to turn on verbose output:
183186
184187` ` ` bash
185- $ $ "<%= $VERBOSE %>" | erb
186- "false"
187- $ echo "<%= $VERBOSE %>" | erb -v
188- "true"
188+ $ echo "<%= \$ VERBOSE %>" | erb
189+ false
190+
191+ $ echo "<%= \$ VERBOSE %>" | erb -v
192+ true
189193` ` `
190194
191- # ## `-v `: Print \ERB Version
195+ # ## `--version `: Print \ERB Version
192196
193197Use option ` --version` to print the \E RB version string:
194198
@@ -205,6 +209,7 @@ which is the Ruby code that is to be run when ERB#result is called:
205209$ cat t.erb
206210<%= RUBY_VERSION %>
207211<%= Time.now %>
212+
208213$ erb -x t.erb
209214#coding:UTF-8
210215_erbout = +''; _erbout.<<(( RUBY_VERSION ).to_s); _erbout.<< "\n".freeze
@@ -230,11 +235,11 @@ The option may be given multiple times to set multiple variables:
230235
231236` ` ` bash
232237$ echo " <%= foo %> <%= bar %>" | erb foo=1 bar=2
233- " 1 2"
238+ 1 2
234239` ` `
235240
236241[erb.new]: https://docs.ruby-lang.org/en/master/ERB.html#method-c-new.
237242[execution tag shorthand]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
238243[options]: rdoc-ref:erb_executable.md@Options
239244[suppressing unwanted blank lines]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines
240- [suppressing unwanted newlines]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
245+ [suppressing unwanted newlines]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
0 commit comments