erb 6.0.5 → 6.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe8090e860af39999944ad5b57ed99f56d5fc6330382c1bc0f466afa94d2ed2d
4
- data.tar.gz: a883d881b398e53f2a9a9daa361330f9529d53062cb7fd786da2c0065a94598a
3
+ metadata.gz: f484b23ae67a9dd0f0e5038f8de3e10b470478d631efea2a5da0f3d26fe393dd
4
+ data.tar.gz: a294f6023602b66ad54e99a39fa90024301964f39e7f6ca68fead5802095c289
5
5
  SHA512:
6
- metadata.gz: 963c8e55a606f7325c7fa7c85cc7b2fe062e1a416db14e8b1012ddf444db75ee53cc1f18a4cc173c61daf492d854c985f1cc861428dfa0d023dcf72d144d1586
7
- data.tar.gz: f4f7bc922fc8dba45007c06ee6ac54ba27cf60bd475687e1c372dff29f7b94ceb37792fb91bec403e8836a5a251bed5b1451f8f4d77c87a866cfe0642ac316e3
6
+ metadata.gz: 508eee6aee771568c731d256b165500ea862d969e7d906f758cec61801b4a0d6963d431e86a808036c1be546448fb5b8e9207180e7625c165a6ea304ffa5994d
7
+ data.tar.gz: e4fd77e01b81307eb28af44959ad1974f4d8b4018e1d4d2923ae850c33569f313b0dbcf0124f279bd7312e74dcb0894ea79d472f4ea5be940f5fd5f634a2f22b
data/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.6
4
+
5
+ * Fix `-h` CLI option
6
+
3
7
  ## 6.0.5
4
8
 
5
9
  * Avoid overridable method dispatch in the initialization guard
data/README.md CHANGED
@@ -8,14 +8,14 @@ ERB is commonly used to produce:
8
8
  - Customized or personalized web pages.
9
9
  - Software code (in code-generating applications).
10
10
 
11
- Like method [sprintf][sprintf], ERB can format run-time data into a string.
12
- ERB, however, is *much more powerful*
11
+ Like method [`sprintf`][sprintf], ERB can format run-time data into a string.
12
+ ERB, however, is *much more powerful*.
13
13
 
14
14
  ## How ERB Works
15
15
 
16
16
  Using ERB, you can create a *template*: a plain-text string that has specially-formatted *tags*,
17
17
  then store it into an ERB object;
18
- when ERB produces _result_ string, it:
18
+ when ERB produces the _result_ string, it:
19
19
 
20
20
  - Inserts run-time-evaluated expressions into the result.
21
21
  - Executes snippets of Ruby code.
@@ -31,30 +31,32 @@ There are three types of tags:
31
31
 
32
32
  | Tag | Form | Action | Text in Result |
33
33
  |----------------|:------------------------------------:|:-------------------------------------:|:--------------------:|
34
- | Expression tag | <tt>'<%= _ruby_expression_ %>'</tt> | Evaluates <tt>_ruby_expression_</tt>. | Value of expression. |
35
- | Execution tag | <tt>'<% _ruby_code_ %>'</tt> | Execute <tt>_ruby_code_</tt>. | None. |
36
- | Comment tag | <tt>'<%# _comment_text_ %>'</tt> | None. | None. |
34
+ | Expression tag | `<%= ruby_expression %>` | Evaluates `ruby_expression`. | Value of expression. |
35
+ | Execution tag | `<% ruby_code %>` | Executes `ruby_code`. | None. |
36
+ | Comment tag | `<%# comment_text %>` | None. | None. |
37
37
 
38
38
  These examples use `erb`, the ERB command-line interface;
39
39
  each "echoes" a string template and pipes it to `erb` as input:
40
40
 
41
41
 
42
42
  - Expression tag:
43
+ ```bash
44
+ $ echo "<%= \$VERBOSE %>" | erb
45
+ false
43
46
 
44
- $ echo "<%= $VERBOSE %>" | erb
45
- "false"
46
- $ echo "<%= 2 + 2 %>" | erb
47
- "4"
48
-
47
+ $ echo "<%= 2 + 2 %>" | erb
48
+ 4
49
+ ```
49
50
  - Execution tag:
50
-
51
- echo "<% if $VERBOSE %> Long message. <% else %> Short message. <% end %>" | erb
52
- " Short message. "
53
-
51
+ ```bash
52
+ $ echo "<% if \$VERBOSE %> Long message. <% else %> Short message. <% end %>" | erb
53
+ Short message.
54
+ ```
54
55
  - Comment tag:
55
-
56
- echo "<%# TODO: Fix this nonsense. %> Nonsense." | erb
57
- " Nonsense."
56
+ ```bash
57
+ $ echo "<%# TODO: Fix this nonsense. %> Nonsense." | erb
58
+ Nonsense.
59
+ ```
58
60
 
59
61
  ## How to Use ERB
60
62
 
@@ -95,4 +97,4 @@ of the [2-Clause BSD License][2-clause bsd license].
95
97
  [ruby/erb]: https://github.com/ruby/erb
96
98
  [ruby toolbox]: https://www.ruby-toolbox.com/categories/template_engines
97
99
  [sprintf]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-sprintf
98
- [template processor]: https://en.wikipedia.org/wiki/Template_processor_
100
+ [template processor]: https://en.wikipedia.org/wiki/Template_processor
@@ -10,12 +10,10 @@ For a quick summary, type:
10
10
  $ erb --help
11
11
  ```
12
12
 
13
- The format of the command is
14
- `erb [_options_] [_filepaths_]`,
15
- where:
13
+ The format of the command is `erb [options] [filepaths]`, where:
16
14
 
17
15
  - _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
19
17
  that can include \ERB tags.
20
18
 
21
19
  ## Filepaths
@@ -27,10 +25,12 @@ that is, `erb` processes multiple files into a single result:
27
25
  $ cat t.erb
28
26
  <%= RUBY_VERSION %>
29
27
  <%= Time.now %>
28
+
30
29
  $ cat u.erb
31
30
  % Encoding.list.take(4).each do |encoding|
32
31
  * <%= encoding %>
33
32
  % end
33
+
34
34
  $ erb t.erb u.erb
35
35
  3.4.5
36
36
  2025-09-24 00:23:00 +0100
@@ -66,21 +66,22 @@ $ echo "<%= RUBY_VERSION %>" | erb # Prints the ERB version string.
66
66
  Use option `-d` or `--debug` to turn on debugging output:
67
67
 
68
68
  ```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
73
74
  ```
74
75
 
75
76
  ### `-E`, `--encoding`: Set Encodings
76
77
 
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`.
79
80
 
80
81
  Each encoding, `ex` and `in`, must be the name of an Encoding:
81
82
 
82
- ```
83
- erb -E ASCII-8BIT:ASCII-8BIT t.erb
83
+ ```bash
84
+ $ erb -E ASCII-8BIT:ASCII-8BIT t.erb
84
85
  ```
85
86
 
86
87
  ### `-h`, `--help`: Print Help
@@ -100,6 +101,7 @@ with numbered lines:
100
101
  $ cat t.erb
101
102
  <%= RUBY_VERSION %>
102
103
  <%= Time.now %>
104
+
103
105
  $ erb -n -x t.erb
104
106
  1 #coding:UTF-8
105
107
  2 _erbout = +''; _erbout.<<(( RUBY_VERSION ).to_s); _erbout.<< "\n".freeze
@@ -119,11 +121,12 @@ $ erb -n t.erb
119
121
 
120
122
  By default, `erb` enables [execution tag shorthand][execution tag shorthand]:
121
123
 
122
- ```
124
+ ```bash
123
125
  $ cat u.erb
124
126
  % Encoding.list.take(4).each do |encoding|
125
127
  * <%= encoding %>
126
128
  % end
129
+
127
130
  $ erb u.erb
128
131
  * ASCII-8BIT
129
132
  * UTF-8
@@ -133,7 +136,7 @@ $ erb u.erb
133
136
 
134
137
  You can use option `-P` to disable the shorthand:
135
138
 
136
- ```
139
+ ```bash
137
140
  $ erb -P u.erb # Raises NameError: "undefined local variable or method 'encoding'"
138
141
  ```
139
142
 
@@ -142,7 +145,7 @@ $ erb -P u.erb # Raises NameError: "undefined local variable or method 'encoding
142
145
  You can use option `-r` to load a library;
143
146
  the option may be given multiple times, to load multiple libraries:
144
147
 
145
- ```
148
+ ```bash
146
149
  $ erb -r csv -r bigdecimal t.erb
147
150
  ```
148
151
 
@@ -182,13 +185,14 @@ $ erb -U t.erb
182
185
  Use option `-v` to turn on verbose output:
183
186
 
184
187
  ```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
189
193
  ```
190
194
 
191
- ### `-v`: Print \ERB Version
195
+ ### `--version`: Print \ERB Version
192
196
 
193
197
  Use option `--version` to print the \ERB version string:
194
198
 
@@ -205,6 +209,7 @@ which is the Ruby code that is to be run when ERB#result is called:
205
209
  $ cat t.erb
206
210
  <%= RUBY_VERSION %>
207
211
  <%= Time.now %>
212
+
208
213
  $ erb -x t.erb
209
214
  #coding:UTF-8
210
215
  _erbout = +''; _erbout.<<(( RUBY_VERSION ).to_s); _erbout.<< "\n".freeze
@@ -230,11 +235,11 @@ The option may be given multiple times to set multiple variables:
230
235
 
231
236
  ```bash
232
237
  $ echo "<%= foo %> <%= bar %>" | erb foo=1 bar=2
233
- "1 2"
238
+ 1 2
234
239
  ```
235
240
 
236
241
  [erb.new]: https://docs.ruby-lang.org/en/master/ERB.html#method-c-new.
237
242
  [execution tag shorthand]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
238
243
  [options]: rdoc-ref:erb_executable.md@Options
239
244
  [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
data/lib/erb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  class ERB
3
3
  # The string \ERB version.
4
- VERSION = '6.0.5'
4
+ VERSION = '6.0.6'
5
5
  end
data/lib/erb.rb CHANGED
@@ -53,7 +53,7 @@ require 'erb/util'
53
53
  #
54
54
  # Here's how \ERB works:
55
55
  #
56
- # - You can create a *template*: a plain-text string that includes specially formatted *tags*..
56
+ # - You can create a *template*: a plain-text string that includes specially formatted *tags*.
57
57
  # - You can create an \ERB object to store the template.
58
58
  # - You can call instance method ERB#result to get the *result*.
59
59
  #
@@ -63,10 +63,12 @@ require 'erb/util'
63
63
  # each begins with `'<%='`, ends with `'%>'`; contains a Ruby expression;
64
64
  # in the result, the value of the expression replaces the entire tag:
65
65
  #
66
- # template = 'The magic word is <%= magic_word %>.'
67
- # erb = ERB.new(template)
68
- # magic_word = 'xyzzy'
69
- # erb.result(binding) # => "The magic word is xyzzy."
66
+ # ```
67
+ # template = 'The magic word is <%= magic_word %>.'
68
+ # erb = ERB.new(template)
69
+ # magic_word = 'xyzzy'
70
+ # erb.result(binding) # => "The magic word is xyzzy."
71
+ # ```
70
72
  #
71
73
  # The above call to #result passes argument `binding`,
72
74
  # which contains the binding of variable `magic_word` to its string value `'xyzzy'`.
@@ -74,21 +76,27 @@ require 'erb/util'
74
76
  # The below call to #result need not pass a binding,
75
77
  # because its expression `Date::DAYNAMES` is globally defined.
76
78
  #
77
- # ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday."
79
+ # ```
80
+ # ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday."
81
+ # ```
78
82
  #
79
83
  # - [Execution tags][execution tags]:
80
84
  # each begins with `'<%'`, ends with `'%>'`; contains Ruby code to be executed:
81
85
  #
82
- # template = '<% File.write("t.txt", "Some stuff.") %>'
83
- # ERB.new(template).result
84
- # File.read('t.txt') # => "Some stuff."
86
+ # ```
87
+ # template = '<% File.write("t.txt", "Some stuff.") %>'
88
+ # ERB.new(template).result
89
+ # File.read('t.txt') # => "Some stuff."
90
+ # ```
85
91
  #
86
92
  # - [Comment tags][comment tags]:
87
93
  # each begins with `'<%#'`, ends with `'%>'`; contains comment text;
88
94
  # in the result, the entire tag is omitted.
89
95
  #
90
- # template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.'
91
- # ERB.new(template).result # => "Some stuff; more stuff."
96
+ # ```
97
+ # template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.'
98
+ # ERB.new(template).result # => "Some stuff; more stuff."
99
+ # ```
92
100
  #
93
101
  # ## Some Simple Examples
94
102
  #
@@ -106,11 +114,10 @@ require 'erb/util'
106
114
  # 1. A plain-text string is assigned to variable `template`.
107
115
  # Its embedded [expression tag][expression tags] `'<%= Time.now %>'` includes a Ruby expression, `Time.now`.
108
116
  # 2. The string is put into a new \ERB object, and stored in variable `erb`.
109
- # 4. Method call `erb.result` generates a string that contains the run-time value of `Time.now`,
117
+ # 3. Method call `erb.result` generates a string that contains the run-time value of `Time.now`,
110
118
  # as computed at the time of the call.
111
119
  #
112
- # The
113
- # \ERB object may be re-used:
120
+ # The \ERB object may be re-used:
114
121
  #
115
122
  # ```
116
123
  # erb.result
@@ -148,14 +155,14 @@ require 'erb/util'
148
155
  # ## Bindings
149
156
  #
150
157
  # A call to method #result, which produces the formatted result string,
151
- # requires a [Binding object][binding object] as its argument.
158
+ # requires a [`Binding` object][binding object] as its argument.
152
159
  #
153
160
  # The binding object provides the bindings for expressions in [expression tags][expression tags].
154
161
  #
155
162
  # There are three ways to provide the required binding:
156
163
  #
157
- # - [Default binding][default binding].
158
- # - [Local binding][local binding].
164
+ # - [Default binding][default binding]
165
+ # - [Local binding][local binding]
159
166
  # - [Augmented binding][augmented binding]
160
167
  #
161
168
  # ### Default Binding
@@ -174,6 +181,9 @@ require 'erb/util'
174
181
  # The current process is <%= $0 %>.
175
182
  # TEMPLATE
176
183
  # puts ERB.new(template).result
184
+ # ```
185
+ #
186
+ # ```
177
187
  # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
178
188
  # The current process is irb.
179
189
  # ```
@@ -183,7 +193,7 @@ require 'erb/util'
183
193
  # ### Local Binding
184
194
  #
185
195
  # The default binding is *not* sufficient for an expression
186
- # that refers to a a constant or variable that is not defined there:
196
+ # that refers to a constant or variable that is not defined there:
187
197
  #
188
198
  # ```
189
199
  # Foo = 1 # Defines local constant Foo.
@@ -209,6 +219,9 @@ require 'erb/util'
209
219
  #
210
220
  # ```
211
221
  # puts erb.result(binding)
222
+ # ```
223
+ #
224
+ # ```
212
225
  # The current value of constant Foo is 1.
213
226
  # The current value of variable foo is 2.
214
227
  # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
@@ -246,6 +259,9 @@ require 'erb/util'
246
259
  # ```
247
260
  # hash = {bar: 3, baz: 4}
248
261
  # puts erb.result_with_hash(hash)
262
+ # ```
263
+ #
264
+ # ```
249
265
  # The current value of variable bar is 3.
250
266
  # The current value of variable baz is 4.
251
267
  # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
@@ -268,7 +284,7 @@ require 'erb/util'
268
284
  #
269
285
  # You can embed a Ruby expression in a template using an *expression tag*.
270
286
  #
271
- # Its syntax is `<%= _expression_ %>`,
287
+ # Its syntax is `<%= expression %>`,
272
288
  # where *expression* is any valid Ruby expression.
273
289
  #
274
290
  # When you call method #result,
@@ -298,7 +314,7 @@ require 'erb/util'
298
314
  #
299
315
  # You can embed Ruby executable code in template using an *execution tag*.
300
316
  #
301
- # Its syntax is `<% _code_ %>`,
317
+ # Its syntax is `<% code %>`,
302
318
  # where *code* is any valid Ruby code.
303
319
  #
304
320
  # When you call method #result,
@@ -306,17 +322,17 @@ require 'erb/util'
306
322
  # (generating no text in the result):
307
323
  #
308
324
  # ```
309
- # ERB.new('foo <% Dir.chdir("C:/") %> bar').result # => "foo bar"
325
+ # ERB.new('foo <% Dir.chdir(Dir.pwd) %> bar').result # => "foo bar"
310
326
  # ```
311
327
  #
312
328
  # Whitespace before and after the embedded code is optional:
313
329
  #
314
330
  # ```
315
- # ERB.new('foo <%Dir.chdir("C:/")%> bar').result # => "foo bar"
331
+ # ERB.new('foo <%Dir.chdir(Dir.pwd)%> bar').result # => "foo bar"
316
332
  # ```
317
333
  #
318
334
  # You can interleave text with execution tags to form a control structure
319
- # such as a conditional, a loop, or a `case` statements.
335
+ # such as a conditional, a loop, or a `case` statement.
320
336
  #
321
337
  # Conditional:
322
338
  #
@@ -386,7 +402,7 @@ require 'erb/util'
386
402
  # #### Shorthand Format for Execution Tags
387
403
  #
388
404
  # You can use keyword argument `trim_mode: '%'` to enable a shorthand format for execution tags;
389
- # this example uses the shorthand format `% _code_` instead of `<% _code_ %>`:
405
+ # this example uses the shorthand format `% code` instead of `<% code %>`:
390
406
  #
391
407
  # ```
392
408
  # template = <<TEMPLATE
@@ -399,6 +415,9 @@ require 'erb/util'
399
415
  # 'Document Modules',
400
416
  # 'Answer Questions on Ruby Talk' ]
401
417
  # puts erb.result(binding)
418
+ # ```
419
+ #
420
+ # ```
402
421
  # * Run Ruby Quiz
403
422
  # * Document Modules
404
423
  # * Answer Questions on Ruby Talk
@@ -419,12 +438,15 @@ require 'erb/util'
419
438
  # <% end %>
420
439
  # TEMPLATE
421
440
  # ERB.new(template).result.lines.each {|line| puts line.inspect }
441
+ # ```
442
+ #
443
+ # ```
422
444
  # "\n"
423
445
  # "3.4.5\n"
424
446
  # "\n"
425
447
  # ```
426
448
  #
427
- # You can give `trim_mode: '-'`, you can suppress each blank line
449
+ # If you give `trim_mode: '-'`, you can suppress each blank line
428
450
  # whose source line ends with `-%>` (instead of `%>`):
429
451
  #
430
452
  # ```
@@ -434,6 +456,9 @@ require 'erb/util'
434
456
  # <% end -%>
435
457
  # TEMPLATE
436
458
  # ERB.new(template, trim_mode: '-').result.lines.each {|line| puts line.inspect }
459
+ # ```
460
+ #
461
+ # ```
437
462
  # "3.4.5\n"
438
463
  # ```
439
464
  #
@@ -460,6 +485,9 @@ require 'erb/util'
460
485
  #
461
486
  # ```
462
487
  # ERB.new(template).result.lines.each {|line| puts line.inspect }
488
+ # ```
489
+ #
490
+ # ```
463
491
  # "\n"
464
492
  # "3.4.5\n"
465
493
  # "foo \n"
@@ -471,6 +499,9 @@ require 'erb/util'
471
499
  #
472
500
  # ```
473
501
  # ERB.new(template, trim_mode: '>').result.lines.each {|line| puts line.inspect }
502
+ # ```
503
+ #
504
+ # ```
474
505
  # "3.4.5foo foo 3.4.5"
475
506
  # ```
476
507
  #
@@ -479,6 +510,9 @@ require 'erb/util'
479
510
  #
480
511
  # ```
481
512
  # ERB.new(template, trim_mode: '<>').result.lines.each {|line| puts line.inspect }
513
+ # ```
514
+ #
515
+ # ```
482
516
  # "3.4.5foo \n"
483
517
  # "foo 3.4.5\n"
484
518
  # ```
@@ -494,7 +528,7 @@ require 'erb/util'
494
528
  # ### Comment Tags
495
529
  #
496
530
  # You can embed a comment in a template using a *comment tag*;
497
- # its syntax is `<%# _text_ %>`,
531
+ # its syntax is `<%# text %>`,
498
532
  # where *text* is the text of the comment.
499
533
  #
500
534
  # When you call method #result,
@@ -570,7 +604,7 @@ require 'erb/util'
570
604
  # erb.filename # => nil
571
605
  # erb.lineno # => 0
572
606
  # erb.result
573
- # (erb):1:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
607
+ # # => (erb):1:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
574
608
  # ```
575
609
  #
576
610
  # You can use methods #filename= and #lineno= to assign values
@@ -580,7 +614,7 @@ require 'erb/util'
580
614
  # erb.filename = 't.txt'
581
615
  # erb.lineno = 555
582
616
  # erb.result
583
- # t.txt:556:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
617
+ # # => t.txt:556:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
584
618
  # ```
585
619
  #
586
620
  # You can use method #location= to set both values:
@@ -588,7 +622,7 @@ require 'erb/util'
588
622
  # ```
589
623
  # erb.location = ['u.txt', 999]
590
624
  # erb.result
591
- # u.txt:1000:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
625
+ # # => u.txt:1000:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
592
626
  # ```
593
627
  #
594
628
  # ## Plain Text with Embedded Ruby
@@ -632,12 +666,14 @@ require 'erb/util'
632
666
  # 'Answer Questions on Ruby Talk' ]
633
667
  # ```
634
668
  #
635
- # Finally, create the \ERB object and get the result
669
+ # Finally, create the \ERB object and get the result:
636
670
  #
637
671
  # ```
638
672
  # erb = ERB.new(template, trim_mode: '%<>')
639
673
  # puts erb.result(binding)
674
+ # ```
640
675
  #
676
+ # ```
641
677
  # From: James Edward Gray II <james@grayproductions.net>
642
678
  # To: Community Spokesman <spokesman@ruby_community.org>
643
679
  # Subject: Addressing Needs
@@ -683,7 +719,6 @@ require 'erb/util'
683
719
  # def get_binding
684
720
  # binding
685
721
  # end
686
- #
687
722
  # end
688
723
  # ```
689
724
  #
@@ -693,8 +728,7 @@ require 'erb/util'
693
728
  # toy = Product.new('TZ-1002',
694
729
  # 'Rubysapien',
695
730
  # "Geek's Best Friend! Responds to Ruby commands...",
696
- # 999.95
697
- # )
731
+ # 999.95)
698
732
  # toy.add_feature('Listens for verbal commands in the Ruby language!')
699
733
  # toy.add_feature('Ignores Perl, Java, and all C variants.')
700
734
  # toy.add_feature('Karate-Chop Action!!!')
@@ -733,6 +767,9 @@ require 'erb/util'
733
767
  # ```
734
768
  # erb = ERB.new(template)
735
769
  # puts erb.result(toy.get_binding)
770
+ # ```
771
+ #
772
+ # ```html
736
773
  # <html>
737
774
  # <head><title>Ruby Toys -- Rubysapien</title></head>
738
775
  # <body>
@@ -758,7 +795,7 @@ require 'erb/util'
758
795
  # Various Ruby projects have their own template processors.
759
796
  # The Ruby Processing System [RDoc][rdoc], for example, has one that can be used elsewhere.
760
797
  #
761
- # Other popular template processors may found in the [Template Engines][template engines] page
798
+ # Other popular template processors may be found in the [Template Engines][template engines] page
762
799
  # of the Ruby Toolbox.
763
800
  #
764
801
  # [%q literals]: https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-25q-3A+Non-Interpolable+String+Literals
@@ -796,7 +833,7 @@ class ERB
796
833
  # :call-seq:
797
834
  # ERB.new(template, trim_mode: nil, eoutvar: '_erbout')
798
835
  #
799
- # Returns a new \ERB object containing the given string +template+.
836
+ # Returns a new \ERB object containing the given string `template`.
800
837
  #
801
838
  # For details about `template`, its embedded tags, and generated results, see ERB.
802
839
  #
@@ -877,13 +914,16 @@ class ERB
877
914
  # In a more readable format:
878
915
  #
879
916
  # ```
880
- # # puts erb.src.split('; ')
881
- # # #coding:UTF-8
882
- # # _erbout = +''
883
- # # _erbout.<< "The time is ".freeze
884
- # # _erbout.<<(( Time.now ).to_s)
885
- # # _erbout.<< ".".freeze
886
- # # _erbout
917
+ # puts erb.src.split('; ')
918
+ # ```
919
+ #
920
+ # ```
921
+ # #coding:UTF-8
922
+ # _erbout = +''
923
+ # _erbout.<< "The time is ".freeze
924
+ # _erbout.<<(( Time.now ).to_s)
925
+ # _erbout.<< ".".freeze
926
+ # _erbout
887
927
  # ```
888
928
  #
889
929
  # Variable `_erbout` is used to store the intermediate results in the code;
@@ -893,6 +933,9 @@ class ERB
893
933
  # ```
894
934
  # erb = ERB.new(template, eoutvar: '_foo')
895
935
  # puts erb.src.split('; ')
936
+ # ```
937
+ #
938
+ # ```
896
939
  # #coding:UTF-8
897
940
  # _foo = +''
898
941
  # _foo.<< "The time is ".freeze
@@ -955,6 +998,9 @@ class ERB
955
998
  # template = ERB.new('')
956
999
  # compiler = template.make_compiler(nil)
957
1000
  # pp compiler
1001
+ # ```
1002
+ #
1003
+ # ```
958
1004
  # #<ERB::Compiler:0x000001cff8a9aa00
959
1005
  # @insert_cmd="print",
960
1006
  # @percent=false,
@@ -962,8 +1008,14 @@ class ERB
962
1008
  # @pre_cmd=[],
963
1009
  # @put_cmd="print",
964
1010
  # @trim_mode=nil>
1011
+ # ```
1012
+ #
1013
+ # ```
965
1014
  # template.set_eoutvar(compiler, '_foo') # => ["_foo"]
966
1015
  # pp compiler
1016
+ # ```
1017
+ #
1018
+ # ```
967
1019
  # #<ERB::Compiler:0x000001cff8a9aa00
968
1020
  # @insert_cmd="_foo.<<",
969
1021
  # @percent=false,
@@ -1091,7 +1143,8 @@ class ERB
1091
1143
  # MyModule = Module.new
1092
1144
  # erb.def_method(MyModule, 'render(arg1, arg2)') # => :render
1093
1145
  # class MyClass; include MyModule; end
1094
- # MyClass.new.render('foo', 123) # => "foo 123"
1146
+ # MyClass.new.render('foo', 123)
1147
+ # # => "foo 123"
1095
1148
  # ```
1096
1149
  #
1097
1150
  def def_method(mod, methodname, fname='(ERB)')
@@ -1114,7 +1167,7 @@ class ERB
1114
1167
  # ```
1115
1168
  # template = '<%= arg1 %> <%= arg2 %>'
1116
1169
  # erb = ERB.new(template)
1117
- # MyModule = template.def_module('render(arg1, arg2)')
1170
+ # MyModule = erb.def_module('render(arg1, arg2)')
1118
1171
  # class MyClass
1119
1172
  # include MyModule
1120
1173
  # end
@@ -1171,6 +1224,9 @@ class ERB
1171
1224
  #
1172
1225
  # ```
1173
1226
  # puts MySubClass.new('foo', 123).render
1227
+ # ```
1228
+ #
1229
+ # ```html
1174
1230
  # <html>
1175
1231
  # <body>
1176
1232
  # <p>foo</p>
data/libexec/erb CHANGED
@@ -89,7 +89,7 @@ class ERB
89
89
  set_encoding(Encoding::UTF_8, Encoding::UTF_8)
90
90
  when '-P'
91
91
  disable_percent = true
92
- when '--help'
92
+ when '-h', '--help'
93
93
  raise ''
94
94
  when /\A-/
95
95
  raise "Unknown switch: #{switch.dump}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.5
4
+ version: 6.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masatoshi SEKI
@@ -50,7 +50,7 @@ licenses:
50
50
  metadata:
51
51
  homepage_uri: https://github.com/ruby/erb
52
52
  source_code_uri: https://github.com/ruby/erb
53
- changelog_uri: https://github.com/ruby/erb/blob/v6.0.5/NEWS.md
53
+ changelog_uri: https://github.com/ruby/erb/blob/v6.0.6/NEWS.md
54
54
  rdoc_options: []
55
55
  require_paths:
56
56
  - lib