erb 5.0.3 → 5.1.0
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 +4 -4
- data/.github/workflows/sync-ruby.yml +2 -2
- data/NEWS.md +4 -0
- data/README.md +14 -14
- data/ext/erb/escape/escape.c +21 -6
- data/lib/erb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f0ce0edaaa7d86d9a02d7062cbf92113d69fc15abeea302b0372b2dac80964
|
4
|
+
data.tar.gz: 95b673abbc9477ed2dc09196bc2f06ce3c81a5cc8dc45612bffc897c8ef1d15f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfd7489d25b0662f8651dcafa1370403c97a7623a78b23835e963590585b4f5fe98c15d64973b3bde4187fcc1698d365ed10acced1f4d842ccdaee8b125363fe
|
7
|
+
data.tar.gz: 0fdfa9071e62c1c35b8104d17cf17e05c24ca91bb64faf22962adc11b03daec1d198ba96ad6165fe17fdd557a736e6dc15bbc90904f69480b67fefe25c0042cb
|
@@ -6,7 +6,7 @@ jobs:
|
|
6
6
|
sync:
|
7
7
|
name: Sync ruby
|
8
8
|
runs-on: ubuntu-latest
|
9
|
-
if: ${{ github.
|
9
|
+
if: ${{ github.repository_owner == 'ruby' }}
|
10
10
|
steps:
|
11
11
|
- uses: actions/checkout@v5
|
12
12
|
|
@@ -28,6 +28,6 @@ jobs:
|
|
28
28
|
github_token: ${{ steps.app-token.outputs.token }}
|
29
29
|
ref: master
|
30
30
|
client_payload: |
|
31
|
-
{"gem":"
|
31
|
+
{"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
|
32
32
|
propagate_failure: true
|
33
33
|
wait_interval: 10
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
#
|
1
|
+
# ERB (Embedded Ruby)
|
2
2
|
|
3
|
-
|
3
|
+
ERB is an easy-to-use, but also very powerful, [template processor][template processor].
|
4
4
|
|
5
|
-
|
5
|
+
ERB is commonly used to produce:
|
6
6
|
|
7
7
|
- Customized or personalized email messages.
|
8
8
|
- Customized or personalized web pages.
|
9
9
|
- Software code (in code-generating applications).
|
10
10
|
|
11
|
-
Like method [sprintf][sprintf],
|
12
|
-
|
11
|
+
Like method [sprintf][sprintf], ERB can format run-time data into a string.
|
12
|
+
ERB, however, is *much more powerful*
|
13
13
|
|
14
|
-
## How
|
14
|
+
## How ERB Works
|
15
15
|
|
16
|
-
Using
|
17
|
-
then store it into an
|
18
|
-
when
|
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
19
|
|
20
20
|
- Inserts run-time-evaluated expressions into the result.
|
21
21
|
- Executes snippets of Ruby code.
|
@@ -35,7 +35,7 @@ There are three types of tags:
|
|
35
35
|
| Execution tag | <tt>'<% _ruby_code_ %>'</tt> | Execute <tt>_ruby_code_</tt>. | None. |
|
36
36
|
| Comment tag | <tt>'<%# _comment_text_ %>'</tt> | None. | None. |
|
37
37
|
|
38
|
-
These examples use `erb`, the
|
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
|
|
@@ -56,16 +56,16 @@ each "echoes" a string template and pipes it to `erb` as input:
|
|
56
56
|
echo "<%# TODO: Fix this nonsense. %> Nonsense." | erb
|
57
57
|
" Nonsense."
|
58
58
|
|
59
|
-
## How to Use
|
59
|
+
## How to Use ERB
|
60
60
|
|
61
|
-
You can use
|
61
|
+
You can use ERB either:
|
62
62
|
|
63
63
|
- In a program: see class ERB.
|
64
64
|
- From the command line: see [ERB Executable][erb executable].
|
65
65
|
|
66
66
|
## Installation
|
67
67
|
|
68
|
-
|
68
|
+
ERB is installed with Ruby, and so there's no further installation needed.
|
69
69
|
|
70
70
|
## Other Template Engines
|
71
71
|
|
@@ -77,7 +77,7 @@ Other popular template engines may be found in the [Ruby Toolbox][ruby toolbox].
|
|
77
77
|
|
78
78
|
## Code
|
79
79
|
|
80
|
-
The
|
80
|
+
The ERB source code is in GitHub project [ruby/erb][ruby/erb].
|
81
81
|
|
82
82
|
## Bugs
|
83
83
|
|
data/ext/erb/escape/escape.c
CHANGED
@@ -39,29 +39,44 @@ static VALUE
|
|
39
39
|
optimized_escape_html(VALUE str)
|
40
40
|
{
|
41
41
|
VALUE vbuf;
|
42
|
-
char *buf =
|
42
|
+
char *buf = NULL;
|
43
43
|
const char *cstr = RSTRING_PTR(str);
|
44
44
|
const char *end = cstr + RSTRING_LEN(str);
|
45
45
|
|
46
|
-
char *
|
46
|
+
const char *segment_start = cstr;
|
47
|
+
char *dest = NULL;
|
47
48
|
while (cstr < end) {
|
48
49
|
const unsigned char c = *cstr++;
|
49
50
|
uint8_t len = html_escape_table[c].len;
|
50
51
|
if (len) {
|
52
|
+
uint16_t segment_len = cstr - segment_start - 1;
|
53
|
+
if (!buf) {
|
54
|
+
buf = ALLOCV_N(char, vbuf, escaped_length(str));
|
55
|
+
dest = buf;
|
56
|
+
}
|
57
|
+
if (segment_len) {
|
58
|
+
memcpy(dest, segment_start, segment_len);
|
59
|
+
dest += segment_len;
|
60
|
+
}
|
61
|
+
segment_start = cstr;
|
51
62
|
memcpy(dest, html_escape_table[c].str, len);
|
52
63
|
dest += len;
|
53
64
|
}
|
54
|
-
|
55
|
-
|
65
|
+
}
|
66
|
+
if (buf) {
|
67
|
+
uint16_t segment_len = cstr - segment_start;
|
68
|
+
if (segment_len) {
|
69
|
+
memcpy(dest, segment_start, segment_len);
|
70
|
+
dest += segment_len;
|
56
71
|
}
|
57
72
|
}
|
58
73
|
|
59
74
|
VALUE escaped = str;
|
60
|
-
if (
|
75
|
+
if (buf) {
|
61
76
|
escaped = rb_str_new(buf, dest - buf);
|
62
77
|
preserve_original_state(str, escaped);
|
78
|
+
ALLOCV_END(vbuf);
|
63
79
|
}
|
64
|
-
ALLOCV_END(vbuf);
|
65
80
|
return escaped;
|
66
81
|
}
|
67
82
|
|
data/lib/erb/version.rb
CHANGED