ed-precompiled_erb 5.0.3-x64-mingw-ucrt
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 +7 -0
- data/.document +6 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/dependabot_automerge.yml +30 -0
- data/.github/workflows/sync-ruby.yml +33 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +12 -0
- data/.rdoc_options +1 -0
- data/BDSL +22 -0
- data/COPYING +56 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +2 -0
- data/NEWS.md +69 -0
- data/README.md +98 -0
- data/Rakefile +19 -0
- data/_doc/cgi.rb +3 -0
- data/_doc/erb_executable.md +240 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/erb.gemspec +36 -0
- data/ext/erb/escape/escape.c +102 -0
- data/ext/erb/escape/extconf.rb +9 -0
- data/lib/erb/3.2/escape.so +0 -0
- data/lib/erb/3.3/escape.so +0 -0
- data/lib/erb/3.4/escape.so +0 -0
- data/lib/erb/compiler.rb +488 -0
- data/lib/erb/def_method.rb +47 -0
- data/lib/erb/escape.so +0 -0
- data/lib/erb/util.rb +77 -0
- data/lib/erb/version.rb +5 -0
- data/lib/erb.rb +1220 -0
- data/libexec/erb +184 -0
- metadata +80 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 10f4f85ecd1781675be3f505376b5cfe3e620704198cfcaf056621ede53ebf63
|
|
4
|
+
data.tar.gz: a5d85d240a491a7de3cb25d4ac6dd0dbc1ea7c2af6050b74844e3b25e04b428e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b1754f84542c12b72daf9a5f1d2c291dc2b931ed7853120237471f78a06c8032673e3b615a7492aa3faa079a5850a8ae99020288f86fb864845e6602eb53de36
|
|
7
|
+
data.tar.gz: 10804770633806abe3965b3bc69d26537ce7932b64b0947bc4241b9b076fe17cc3fd8bade279b9eb3eaa60cd32b5e4145b90f5f6a05afcdb6d6b2cc73a149482
|
data/.document
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Dependabot auto-merge
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
|
|
5
|
+
permissions:
|
|
6
|
+
contents: write
|
|
7
|
+
pull-requests: write
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
automerge:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ruby/erb'
|
|
13
|
+
steps:
|
|
14
|
+
- name: Dependabot metadata
|
|
15
|
+
uses: dependabot/fetch-metadata@v2
|
|
16
|
+
id: metadata
|
|
17
|
+
|
|
18
|
+
- name: Wait for status checks
|
|
19
|
+
uses: lewagon/wait-on-check-action@v1
|
|
20
|
+
with:
|
|
21
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
22
|
+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
23
|
+
check-regexp: 'build \(.*\)'
|
|
24
|
+
wait-interval: 30
|
|
25
|
+
|
|
26
|
+
- name: Auto-merge for Dependabot PRs
|
|
27
|
+
run: gh pr merge --auto --rebase "$PR_URL"
|
|
28
|
+
env:
|
|
29
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.MATZBOT_DEPENDABOT_MERGE_TOKEN }}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Sync ruby
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [master]
|
|
5
|
+
jobs:
|
|
6
|
+
sync:
|
|
7
|
+
name: Sync ruby
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
if: ${{ github.repository_owner == 'ruby' }}
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v5
|
|
12
|
+
|
|
13
|
+
- name: Create GitHub App token
|
|
14
|
+
id: app-token
|
|
15
|
+
uses: actions/create-github-app-token@v2
|
|
16
|
+
with:
|
|
17
|
+
app-id: 2060836
|
|
18
|
+
private-key: ${{ secrets.RUBY_SYNC_DEFAULT_GEMS_PRIVATE_KEY }}
|
|
19
|
+
owner: ruby
|
|
20
|
+
repositories: ruby
|
|
21
|
+
|
|
22
|
+
- name: Sync to ruby/ruby
|
|
23
|
+
uses: convictional/trigger-workflow-and-wait@v1.6.5
|
|
24
|
+
with:
|
|
25
|
+
owner: ruby
|
|
26
|
+
repo: ruby
|
|
27
|
+
workflow_file_name: sync_default_gems.yml
|
|
28
|
+
github_token: ${{ steps.app-token.outputs.token }}
|
|
29
|
+
ref: master
|
|
30
|
+
client_payload: |
|
|
31
|
+
{"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
|
|
32
|
+
propagate_failure: true
|
|
33
|
+
wait_interval: 10
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
ruby-versions:
|
|
11
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
12
|
+
with:
|
|
13
|
+
engine: cruby
|
|
14
|
+
versions: '["jruby", "truffleruby-head"]'
|
|
15
|
+
|
|
16
|
+
test:
|
|
17
|
+
needs: ruby-versions
|
|
18
|
+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
|
19
|
+
strategy:
|
|
20
|
+
matrix:
|
|
21
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
22
|
+
os: [ubuntu-latest]
|
|
23
|
+
fail-fast: false
|
|
24
|
+
runs-on: ${{ matrix.os }}
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v5
|
|
27
|
+
- name: Set up Ruby
|
|
28
|
+
uses: ruby/setup-ruby@v1
|
|
29
|
+
with:
|
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
|
31
|
+
bundler-cache: true
|
|
32
|
+
- name: Run test
|
|
33
|
+
run: bundle exec rake test
|
|
34
|
+
- name: RDoc coverage
|
|
35
|
+
run: |
|
|
36
|
+
rdoc -C .
|
data/.gitignore
ADDED
data/.rdoc_options
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
main_page: README.md
|
data/BDSL
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions
|
|
5
|
+
are met:
|
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
documentation and/or other materials provided with the distribution.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
22
|
+
SUCH DAMAGE.
|
data/COPYING
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
|
4
|
+
|
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
6
|
+
software without restriction, provided that you duplicate all of the
|
|
7
|
+
original copyright notices and associated disclaimers.
|
|
8
|
+
|
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
|
10
|
+
you do at least ONE of the following:
|
|
11
|
+
|
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
|
13
|
+
make them Freely Available, such as by posting said
|
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
15
|
+
the author to include your modifications in the software.
|
|
16
|
+
|
|
17
|
+
b. use the modified software only within your corporation or
|
|
18
|
+
organization.
|
|
19
|
+
|
|
20
|
+
c. give non-standard binaries non-standard names, with
|
|
21
|
+
instructions on where to get the original software distribution.
|
|
22
|
+
|
|
23
|
+
d. make other distribution arrangements with the author.
|
|
24
|
+
|
|
25
|
+
3. You may distribute the software in object code or binary form,
|
|
26
|
+
provided that you do at least ONE of the following:
|
|
27
|
+
|
|
28
|
+
a. distribute the binaries and library files of the software,
|
|
29
|
+
together with instructions (in the manual page or equivalent)
|
|
30
|
+
on where to get the original distribution.
|
|
31
|
+
|
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
|
33
|
+
the software.
|
|
34
|
+
|
|
35
|
+
c. give non-standard binaries non-standard names, with
|
|
36
|
+
instructions on where to get the original software distribution.
|
|
37
|
+
|
|
38
|
+
d. make other distribution arrangements with the author.
|
|
39
|
+
|
|
40
|
+
4. You may modify and include the part of the software into any other
|
|
41
|
+
software (possibly commercial). But some files in the distribution
|
|
42
|
+
are not written by the author, so that they are not under these terms.
|
|
43
|
+
|
|
44
|
+
For the list of those files and their copying conditions, see the
|
|
45
|
+
file LEGAL.
|
|
46
|
+
|
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
|
48
|
+
output from the software do not automatically fall under the
|
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
|
51
|
+
software.
|
|
52
|
+
|
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
56
|
+
PURPOSE.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
data/NEWS.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## 5.0.3
|
|
4
|
+
|
|
5
|
+
* Update help of erb(1) [#85](https://github.com/ruby/erb/pull/85)
|
|
6
|
+
|
|
7
|
+
## 5.0.2
|
|
8
|
+
|
|
9
|
+
* Declare escape functions as Ractor-safe [#63](https://github.com/ruby/erb/pull/63)
|
|
10
|
+
|
|
11
|
+
## 5.0.1
|
|
12
|
+
|
|
13
|
+
* Rescue `LoadError` when failing to load `erb/escape`
|
|
14
|
+
|
|
15
|
+
## 5.0.0
|
|
16
|
+
|
|
17
|
+
* Bump `required_ruby_version` to Ruby 3.2+ [#60](https://github.com/ruby/erb/pull/60)
|
|
18
|
+
* Drop `cgi` from runtime dependencies [#59](https://github.com/ruby/erb/pull/59)
|
|
19
|
+
* Make `ERB::VERSION` public
|
|
20
|
+
|
|
21
|
+
## 4.0.4
|
|
22
|
+
|
|
23
|
+
* Skip building the C extension for JRuby [#52](https://github.com/ruby/erb/pull/52)
|
|
24
|
+
|
|
25
|
+
## 4.0.3
|
|
26
|
+
|
|
27
|
+
* Enable `frozen_string_literal` in all files [#49](https://github.com/ruby/erb/pull/49)
|
|
28
|
+
|
|
29
|
+
## 4.0.2
|
|
30
|
+
|
|
31
|
+
* Fix line numbers after multi-line `<%#` [#42](https://github.com/ruby/erb/pull/42)
|
|
32
|
+
|
|
33
|
+
## 4.0.1
|
|
34
|
+
|
|
35
|
+
* Stop building the C extension for TruffleRuby [#39](https://github.com/ruby/erb/pull/39)
|
|
36
|
+
|
|
37
|
+
## 4.0.0
|
|
38
|
+
|
|
39
|
+
* Optimize `ERB::Util.html_escape` [#27](https://github.com/ruby/erb/pull/27)
|
|
40
|
+
* No longer duplicate an argument string when nothing is escaped.
|
|
41
|
+
* This makes `ERB::Util.html_escape` faster than `CGI.escapeHTML` in no-escape cases.
|
|
42
|
+
* It skips calling `#to_s` when an argument is already a String.
|
|
43
|
+
* Define `ERB::Escape.html_escape` as an alias to `ERB::Util.html_escape` [#38](https://github.com/ruby/erb/pull/38)
|
|
44
|
+
* `ERB::Util.html_escape` is known to be monkey-patched by Rails.
|
|
45
|
+
`ERB::Escape.html_escape` is useful when you want a non-monkey-patched version.
|
|
46
|
+
* Drop deprecated `-S` option from `erb` command
|
|
47
|
+
|
|
48
|
+
## 3.0.0
|
|
49
|
+
|
|
50
|
+
* Bump `required_ruby_version` to Ruby 2.7+ [#23](https://github.com/ruby/erb/pull/23)
|
|
51
|
+
* `ERB::Util.url_encode` uses a native implementation [#23](https://github.com/ruby/erb/pull/23)
|
|
52
|
+
* Fix a bug that a magic comment with a wrong format could be detected [#6](https://github.com/ruby/erb/pull/6)
|
|
53
|
+
|
|
54
|
+
## 2.2.3
|
|
55
|
+
|
|
56
|
+
* Bump `required_ruby_version` from 2.3 to 2.5 as it has never been supported [#3](https://github.com/ruby/erb/pull/3)
|
|
57
|
+
|
|
58
|
+
## 2.2.2
|
|
59
|
+
|
|
60
|
+
* `ERB.version` returns just a version number
|
|
61
|
+
* `ERB::Revision` is deprecated
|
|
62
|
+
|
|
63
|
+
## 2.2.1
|
|
64
|
+
|
|
65
|
+
* `ERB#initialize` warns `safe_level` and later arguments even without -w
|
|
66
|
+
|
|
67
|
+
## 2.2.0
|
|
68
|
+
|
|
69
|
+
* Ruby 3.0 promoted ERB to a default gem
|
data/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# ERB (Embedded Ruby)
|
|
2
|
+
|
|
3
|
+
ERB is an easy-to-use, but also very powerful, [template processor][template processor].
|
|
4
|
+
|
|
5
|
+
ERB is commonly used to produce:
|
|
6
|
+
|
|
7
|
+
- Customized or personalized email messages.
|
|
8
|
+
- Customized or personalized web pages.
|
|
9
|
+
- Software code (in code-generating applications).
|
|
10
|
+
|
|
11
|
+
Like method [sprintf][sprintf], ERB can format run-time data into a string.
|
|
12
|
+
ERB, however, is *much more powerful*
|
|
13
|
+
|
|
14
|
+
## How ERB Works
|
|
15
|
+
|
|
16
|
+
Using ERB, you can create a *template*: a plain-text string that has specially-formatted *tags*,
|
|
17
|
+
then store it into an ERB object;
|
|
18
|
+
when ERB produces _result_ string, it:
|
|
19
|
+
|
|
20
|
+
- Inserts run-time-evaluated expressions into the result.
|
|
21
|
+
- Executes snippets of Ruby code.
|
|
22
|
+
- Omits comments from the results.
|
|
23
|
+
|
|
24
|
+
In the result:
|
|
25
|
+
|
|
26
|
+
- All non-tag text is passed through, _unchanged_.
|
|
27
|
+
- Each tag is either _replaced_ (expression tag),
|
|
28
|
+
or _omitted_ entirely (execution tag or comment tag).
|
|
29
|
+
|
|
30
|
+
There are three types of tags:
|
|
31
|
+
|
|
32
|
+
| Tag | Form | Action | Text in Result |
|
|
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. |
|
|
37
|
+
|
|
38
|
+
These examples use `erb`, the ERB command-line interface;
|
|
39
|
+
each "echoes" a string template and pipes it to `erb` as input:
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
- Expression tag:
|
|
43
|
+
|
|
44
|
+
$ echo "<%= $VERBOSE %>" | erb
|
|
45
|
+
"false"
|
|
46
|
+
$ echo "<%= 2 + 2 %>" | erb
|
|
47
|
+
"4"
|
|
48
|
+
|
|
49
|
+
- Execution tag:
|
|
50
|
+
|
|
51
|
+
echo "<% if $VERBOSE %> Long message. <% else %> Short message. <% end %>" | erb
|
|
52
|
+
" Short message. "
|
|
53
|
+
|
|
54
|
+
- Comment tag:
|
|
55
|
+
|
|
56
|
+
echo "<%# TODO: Fix this nonsense. %> Nonsense." | erb
|
|
57
|
+
" Nonsense."
|
|
58
|
+
|
|
59
|
+
## How to Use ERB
|
|
60
|
+
|
|
61
|
+
You can use ERB either:
|
|
62
|
+
|
|
63
|
+
- In a program: see class ERB.
|
|
64
|
+
- From the command line: see [ERB Executable][erb executable].
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
ERB is installed with Ruby, and so there's no further installation needed.
|
|
69
|
+
|
|
70
|
+
## Other Template Engines
|
|
71
|
+
|
|
72
|
+
There are a variety of template engines available in various Ruby projects.
|
|
73
|
+
For example, [RDoc][rdoc], distributed with Ruby, uses its own template engine, which
|
|
74
|
+
can be reused elsewhere.
|
|
75
|
+
|
|
76
|
+
Other popular template engines may be found in the [Ruby Toolbox][ruby toolbox].
|
|
77
|
+
|
|
78
|
+
## Code
|
|
79
|
+
|
|
80
|
+
The ERB source code is in GitHub project [ruby/erb][ruby/erb].
|
|
81
|
+
|
|
82
|
+
## Bugs
|
|
83
|
+
|
|
84
|
+
Bugs may be reported at [ERB Issues][erb issues].
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
This software is available as open source under the terms
|
|
89
|
+
of the [2-Clause BSD License][2-clause bsd license].
|
|
90
|
+
|
|
91
|
+
[2-clause bsd license]: https://opensource.org/licenses/BSD-2-Clause
|
|
92
|
+
[erb executable]: rdoc-ref:erb_executable.md
|
|
93
|
+
[erb issues]: https://github.com/ruby/erb/issues
|
|
94
|
+
[rdoc]: https://ruby.github.io/rdoc/
|
|
95
|
+
[ruby/erb]: https://github.com/ruby/erb
|
|
96
|
+
[ruby toolbox]: https://www.ruby-toolbox.com/categories/template_engines
|
|
97
|
+
[sprintf]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-sprintf
|
|
98
|
+
[template processor]: https://en.wikipedia.org/wiki/Template_processor_
|
data/Rakefile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
|
5
|
+
t.libs << 'test/lib'
|
|
6
|
+
t.ruby_opts << '-rhelper'
|
|
7
|
+
t.test_files = FileList['test/**/test_*.rb']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
case RUBY_ENGINE
|
|
11
|
+
when 'jruby', 'truffleruby'
|
|
12
|
+
# not using C extension
|
|
13
|
+
else
|
|
14
|
+
require 'rake/extensiontask'
|
|
15
|
+
Rake::ExtensionTask.new('erb/escape')
|
|
16
|
+
task test: :compile
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
task default: :test
|
data/_doc/cgi.rb
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# \ERB Executable
|
|
2
|
+
|
|
3
|
+
The `erb` executable gives command-line access to ERB template processing.
|
|
4
|
+
|
|
5
|
+
The executable is installed with \ERB, which is part of the Ruby installation.
|
|
6
|
+
|
|
7
|
+
For a quick summary, type:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ erb --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The format of the command is
|
|
14
|
+
`erb [_options_] [_filepaths_]`,
|
|
15
|
+
where:
|
|
16
|
+
|
|
17
|
+
- _options_ are zero or more [options][options].
|
|
18
|
+
- _filepaths_ are zero or more paths to files, each containing an plain text
|
|
19
|
+
that can include \ERB tags.
|
|
20
|
+
|
|
21
|
+
## Filepaths
|
|
22
|
+
|
|
23
|
+
With one or more _filepaths_ given, `erb` reads all the given files as a single template;
|
|
24
|
+
that is, `erb` processes multiple files into a single result:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
$ cat t.erb
|
|
28
|
+
<%= RUBY_VERSION %>
|
|
29
|
+
<%= Time.now %>
|
|
30
|
+
$ cat u.erb
|
|
31
|
+
% Encoding.list.take(4).each do |encoding|
|
|
32
|
+
* <%= encoding %>
|
|
33
|
+
% end
|
|
34
|
+
$ erb t.erb u.erb
|
|
35
|
+
3.4.5
|
|
36
|
+
2025-09-24 00:23:00 +0100
|
|
37
|
+
* ASCII-8BIT
|
|
38
|
+
* UTF-8
|
|
39
|
+
* US-ASCII
|
|
40
|
+
* UTF-16BE
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
There is a special "filepath", `'-'`, that specifies the standard input:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
$ echo "<%= RUBY_VERSION %>" | erb u.erb -
|
|
47
|
+
* ASCII-8BIT
|
|
48
|
+
* UTF-8
|
|
49
|
+
* US-ASCII
|
|
50
|
+
* UTF-16BE
|
|
51
|
+
3.4.5
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Any filepath, including `'-'`, may be repeated.
|
|
55
|
+
|
|
56
|
+
With no _filepaths_ given, `erb` reads and processes the standard input:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
$ echo "<%= RUBY_VERSION %>" | erb # Prints the ERB version string.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Options
|
|
63
|
+
|
|
64
|
+
### `-d`, `--debug`: Set $DEBUG
|
|
65
|
+
|
|
66
|
+
Use option `-d` or `--debug` to turn on debugging output:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
$ echo "<%= $DEBUG %>" | erb
|
|
70
|
+
"false"
|
|
71
|
+
$echo "<%= $DEBUG %>" | erb --debug
|
|
72
|
+
"true"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `-E`, `--encoding`: Set Encodings
|
|
76
|
+
|
|
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_`.
|
|
79
|
+
|
|
80
|
+
Each encoding, `ex` and `in`, must be the name of an Encoding:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
erb -E ASCII-8BIT:ASCII-8BIT t.erb
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `-h`, `--help`: Print Help
|
|
87
|
+
|
|
88
|
+
Use option `-h` or `--help` to print `erb` help text:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
$ erb --help
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `-n`: Print Source with Line Numbers
|
|
95
|
+
|
|
96
|
+
Use option `-n` with option `-x` to print the output of ERB#src,
|
|
97
|
+
with numbered lines:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
$ cat t.erb
|
|
101
|
+
<%= RUBY_VERSION %>
|
|
102
|
+
<%= Time.now %>
|
|
103
|
+
$ erb -n -x t.erb
|
|
104
|
+
1 #coding:UTF-8
|
|
105
|
+
2 _erbout = +''; _erbout.<<(( RUBY_VERSION ).to_s); _erbout.<< "\n".freeze
|
|
106
|
+
3 ; _erbout.<<(( Time.now ).to_s); _erbout.<< "\n".freeze
|
|
107
|
+
4 ; _erbout
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Using option `-n` without option `-x` has no effect:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
$ erb -n t.erb
|
|
114
|
+
3.4.5
|
|
115
|
+
2025-09-23 02:44:57 +0100
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `-P`: Disable Execution Tag Shorthand
|
|
119
|
+
|
|
120
|
+
By default, `erb` enables [execution tag shorthand][execution tag shorthand]:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
$ cat u.erb
|
|
124
|
+
% Encoding.list.take(4).each do |encoding|
|
|
125
|
+
* <%= encoding %>
|
|
126
|
+
% end
|
|
127
|
+
$ erb u.erb
|
|
128
|
+
* ASCII-8BIT
|
|
129
|
+
* UTF-8
|
|
130
|
+
* US-ASCII
|
|
131
|
+
* UTF-16BE
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
You can use option `-P` to disable the shorthand:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
$ erb -P u.erb # Raises NameError: "undefined local variable or method 'encoding'"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### `-r`: Load Library
|
|
141
|
+
|
|
142
|
+
You can use option `-r` to load a library;
|
|
143
|
+
the option may be given multiple times, to load multiple libraries:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
$ erb -r csv -r bigdecimal t.erb
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `-T`: Set Trim Mode
|
|
150
|
+
|
|
151
|
+
You can use option `-T` to set the trim mode.
|
|
152
|
+
|
|
153
|
+
The values for the option are:
|
|
154
|
+
|
|
155
|
+
- `'0'`, meaning `'%'`; enable execution tag shorthand;
|
|
156
|
+
see [execution tag shorthand][execution tag shorthand].
|
|
157
|
+
- `'1'`, meaning `'%>'`: enable execution tag shorthand and omit newline for each line ending with `'%>'`;
|
|
158
|
+
see [suppressing unwanted newlines][suppressing unwanted newlines].
|
|
159
|
+
- `'2'`, meaning `'<>'`: to suppress the trailing newline for each line
|
|
160
|
+
that both begins with `'<%'` and ends with `'%>'`;
|
|
161
|
+
see [suppressing unwanted newlines][suppressing unwanted newlines].
|
|
162
|
+
- `'-'`, meaning `'%-'`: enable execution tag shorthand and omit each blank line ending with `'-%>'`.
|
|
163
|
+
see [execution tag shorthand][execution tag shorthand]
|
|
164
|
+
and [suppressing unwanted blank lines][suppressing unwanted blank lines].
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
$ erb -T 0 t.erb
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### `-U`: Set Default Encodings to UTF-8
|
|
173
|
+
|
|
174
|
+
You can use option `-U` to set both external and internal encodings to UTF-8:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
$ erb -U t.erb
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `-v`: Set $VERBOSE
|
|
181
|
+
|
|
182
|
+
Use option `-v` to turn on verbose output:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
$ $ "<%= $VERBOSE %>" | erb
|
|
186
|
+
"false"
|
|
187
|
+
$ echo "<%= $VERBOSE %>" | erb -v
|
|
188
|
+
"true"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `-v`: Print \ERB Version
|
|
192
|
+
|
|
193
|
+
Use option `--version` to print the \ERB version string:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
$ erb --version
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### `-x`: Print Source
|
|
200
|
+
|
|
201
|
+
Use option `-x` to print the output of ERB#src,
|
|
202
|
+
which is the Ruby code that is to be run when ERB#result is called:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
$ cat t.erb
|
|
206
|
+
<%= RUBY_VERSION %>
|
|
207
|
+
<%= Time.now %>
|
|
208
|
+
$ erb -x t.erb
|
|
209
|
+
#coding:UTF-8
|
|
210
|
+
_erbout = +''; _erbout.<<(( RUBY_VERSION ).to_s); _erbout.<< "\n".freeze
|
|
211
|
+
; _erbout.<<(( Time.now ).to_s); _erbout.<< "\n".freeze
|
|
212
|
+
; _erbout
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### `--`: End of Options
|
|
216
|
+
|
|
217
|
+
You can use option `'--'` to declare the end of options in the `erb` command;
|
|
218
|
+
`erb` treats each word following as a filepath (even if it looks like an option):
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
erb -- --help # Raises Errno::ENOENT: "No such file or directory @ rb_sysopen - --help"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### `name=value`: Set the Value of a Variable
|
|
225
|
+
|
|
226
|
+
You can use option `name=value` to set the value of the variable named `name`
|
|
227
|
+
to the given `value`.
|
|
228
|
+
|
|
229
|
+
The option may be given multiple times to set multiple variables:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
$ echo "<%= foo %> <%= bar %>" | erb foo=1 bar=2
|
|
233
|
+
"1 2"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
[erb.new]: https://docs.ruby-lang.org/en/master/ERB.html#method-c-new.
|
|
237
|
+
[execution tag shorthand]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
|
|
238
|
+
[options]: rdoc-ref:erb_executable.md@Options
|
|
239
|
+
[suppressing unwanted blank lines]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines
|
|
240
|
+
[suppressing unwanted newlines]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "erb"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|