Skip to content

Commit 37daba6

Browse files
authored
Fix documentation typos and code examples (#125)
Makes documentation-only changes. Summary: - Fix typos and grammar - Fix invalid code examples - Fix syntax highlighting in code examples - Fix invalid Markdown tags
1 parent 37c941c commit 37daba6

3 files changed

Lines changed: 148 additions & 85 deletions

File tree

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ ERB is commonly used to produce:
88
- Customized or personalized web pages.
99
- Software code (in code-generating applications).
1010

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*.
1313

1414
## How ERB Works
1515

1616
Using ERB, you can create a *template*: a plain-text string that has specially-formatted *tags*,
1717
then store it into an ERB object;
18-
when ERB produces _result_ string, it:
18+
when ERB produces the _result_ string, it:
1919

2020
- Inserts run-time-evaluated expressions into the result.
2121
- Executes snippets of Ruby code.
@@ -31,30 +31,32 @@ There are three types of tags:
3131

3232
| Tag | Form | Action | Text in Result |
3333
|----------------|:------------------------------------:|:-------------------------------------:|:--------------------:|
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. |
3737

3838
These examples use `erb`, the ERB command-line interface;
3939
each "echoes" a string template and pipes it to `erb` as input:
4040

4141

4242
- Expression tag:
43+
```bash
44+
$ echo "<%= \$VERBOSE %>" | erb
45+
false
4346

44-
$ echo "<%= $VERBOSE %>" | erb
45-
"false"
46-
$ echo "<%= 2 + 2 %>" | erb
47-
"4"
48-
47+
$ echo "<%= 2 + 2 %>" | erb
48+
4
49+
```
4950
- 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+
```
5455
- 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+
```
5860

5961
## How to Use ERB
6062

@@ -95,4 +97,4 @@ of the [2-Clause BSD License][2-clause bsd license].
9597
[ruby/erb]: https://github.com/ruby/erb
9698
[ruby toolbox]: https://www.ruby-toolbox.com/categories/template_engines
9799
[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

_doc/erb_executable.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3535
3.4.5
3636
2025-09-24 00:23:00 +0100
@@ -66,21 +66,22 @@ $ echo "<%= RUBY_VERSION %>" | erb # Prints the ERB version string.
6666
Use 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

8081
Each 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
120122
By 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
134137
You 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
142145
You can use option `-r` to load a library;
143146
the 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
182185
Use 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
193197
Use option `--version` to print the \ERB 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

Comments
 (0)