erubis 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +150 -2
- data/LGPL +504 -0
- data/README.txt +14 -8
- data/benchmark/erubybench.rb +1 -1
- data/benchmark/erubybench.rhtml +3 -3
- data/bin/erubis +1 -1
- data/bin/notext +154 -0
- data/contrib/erubis +1036 -374
- data/contrib/inline-require +5 -3
- data/doc-api/classes/Erubis.html +43 -1
- data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/ArrayEnhancer.html +14 -14
- data/doc-api/classes/Erubis/Basic.html +112 -0
- data/doc-api/classes/Erubis/Basic/Converter.html +318 -0
- data/doc-api/classes/Erubis/Basic/Engine.html +130 -0
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
- data/doc-api/classes/Erubis/CGenerator.html +386 -0
- data/doc-api/classes/Erubis/Context.html +31 -32
- data/doc-api/classes/Erubis/Converter.html +231 -0
- data/doc-api/classes/Erubis/Ec.html +9 -283
- data/doc-api/classes/Erubis/Ejava.html +9 -274
- data/doc-api/classes/Erubis/Ejavascript.html +9 -298
- data/doc-api/classes/Erubis/Engine.html +68 -508
- data/doc-api/classes/Erubis/Eperl.html +9 -259
- data/doc-api/classes/Erubis/Ephp.html +9 -239
- data/doc-api/classes/Erubis/ErubisError.html +2 -2
- data/doc-api/classes/Erubis/Eruby.html +4 -187
- data/doc-api/classes/Erubis/EscapeEnhancer.html +9 -11
- data/doc-api/classes/Erubis/Escheme.html +9 -272
- data/doc-api/classes/Erubis/Evaluator.html +212 -0
- data/doc-api/classes/Erubis/Generator.html +410 -0
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +16 -16
- data/doc-api/classes/Erubis/Helper.html +112 -0
- data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +198 -0
- data/doc-api/classes/Erubis/Helper/RailsTemplate.html +366 -0
- data/doc-api/classes/Erubis/JavaGenerator.html +359 -0
- data/doc-api/classes/Erubis/JavascriptGenerator.html +381 -0
- data/doc-api/classes/Erubis/Main.html +27 -25
- data/doc-api/classes/Erubis/NoCodeEnhancer.html +249 -0
- data/doc-api/classes/Erubis/NoCodeEruby.html +120 -0
- data/doc-api/classes/Erubis/NoTextEnhancer.html +8 -8
- data/doc-api/classes/Erubis/NotSupportedError.html +119 -0
- data/doc-api/classes/Erubis/OptimizedEruby.html +22 -304
- data/doc-api/classes/Erubis/OptimizedGenerator.html +439 -0
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +7 -7
- data/doc-api/classes/Erubis/PI.html +124 -0
- data/doc-api/classes/Erubis/PI/Converter.html +318 -0
- data/doc-api/classes/Erubis/PI/Ec.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejava.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejavascript.html +166 -0
- data/doc-api/classes/Erubis/PI/Engine.html +122 -0
- data/doc-api/classes/Erubis/PI/Eperl.html +166 -0
- data/doc-api/classes/Erubis/PI/Ephp.html +166 -0
- data/doc-api/classes/Erubis/PI/Eruby.html +155 -0
- data/doc-api/classes/Erubis/PI/Escheme.html +166 -0
- data/doc-api/classes/Erubis/PI/TinyEruby.html +305 -0
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +7 -7
- data/doc-api/classes/Erubis/PerlGenerator.html +344 -0
- data/doc-api/classes/Erubis/PhpGenerator.html +350 -0
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +24 -24
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +35 -35
- data/doc-api/classes/Erubis/RubyEvaluator.html +190 -0
- data/doc-api/classes/Erubis/RubyGenerator.html +327 -0
- data/doc-api/classes/Erubis/SchemeGenerator.html +382 -0
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +17 -13
- data/doc-api/classes/Erubis/StdoutEnhancer.html +14 -14
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/TinyEruby.html +45 -40
- data/doc-api/classes/Erubis/XmlHelper.html +14 -14
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +27 -9
- data/doc-api/files/erubis/context_rb.html +107 -0
- data/doc-api/files/erubis/converter_rb.html +114 -0
- data/doc-api/files/erubis/engine/ec_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
- data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
- data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
- data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
- data/doc-api/files/erubis/engine/eruby_rb.html +3 -2
- data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
- data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
- data/doc-api/files/erubis/engine_rb.html +6 -3
- data/doc-api/files/erubis/enhancer_rb.html +2 -9
- data/doc-api/files/erubis/error_rb.html +107 -0
- data/doc-api/files/erubis/evaluator_rb.html +115 -0
- data/doc-api/files/erubis/generator_rb.html +114 -0
- data/doc-api/files/erubis/helper/rails_rb.html +140 -0
- data/doc-api/files/erubis/helper_rb.html +1 -1
- data/doc-api/files/erubis/local-setting_rb.html +1 -1
- data/doc-api/files/erubis/main_rb.html +2 -2
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +32 -0
- data/doc-api/fr_file_index.html +6 -0
- data/doc-api/fr_method_index.html +178 -136
- data/doc/users-guide.html +538 -199
- data/examples/{Makefile → basic/Makefile} +11 -11
- data/examples/basic/example.ec +42 -0
- data/examples/{example.ejava → basic/example.ejava} +5 -1
- data/examples/{example.ejavascript → basic/example.ejs} +0 -0
- data/examples/{example.eperl → basic/example.eperl} +2 -2
- data/examples/{example.ephp → basic/example.ephp} +0 -0
- data/examples/{example.eruby → basic/example.eruby} +0 -0
- data/examples/{example.escheme → basic/example.escheme} +0 -0
- data/examples/pi/Makefile +54 -0
- data/examples/pi/example.ec +42 -0
- data/examples/pi/example.ejava +45 -0
- data/examples/pi/example.ejs +16 -0
- data/examples/pi/example.eperl +16 -0
- data/examples/pi/example.ephp +17 -0
- data/examples/pi/example.eruby +15 -0
- data/examples/pi/example.escheme +26 -0
- data/lib/erubis.rb +15 -8
- data/lib/erubis/context.rb +54 -0
- data/lib/erubis/converter.rb +307 -0
- data/lib/erubis/engine.rb +57 -227
- data/lib/erubis/engine/ec.rb +31 -20
- data/lib/erubis/engine/ejava.rb +33 -21
- data/lib/erubis/engine/ejavascript.rb +30 -18
- data/lib/erubis/engine/enhanced.rb +7 -2
- data/lib/erubis/engine/eperl.rb +33 -19
- data/lib/erubis/engine/ephp.rb +32 -14
- data/lib/erubis/engine/eruby.rb +34 -7
- data/lib/erubis/engine/escheme.rb +34 -15
- data/lib/erubis/engine/optimized.rb +25 -11
- data/lib/erubis/enhancer.rb +53 -19
- data/lib/erubis/error.rb +24 -0
- data/lib/erubis/evaluator.rb +71 -0
- data/lib/erubis/generator.rb +83 -0
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helper/rails.rb +159 -0
- data/lib/erubis/local-setting.rb +1 -1
- data/lib/erubis/main.rb +87 -46
- data/lib/erubis/tiny.rb +81 -7
- data/test/assert-text-equal.rb +1 -1
- data/test/test-engines.rb +8 -9
- data/test/test-erubis.rb +196 -18
- data/test/{test-bin.rb → test-main.rb} +123 -21
- data/test/test-notext.rb +27 -0
- data/test/test.rb +5 -3
- data/test/testutil.rb +25 -36
- metadata +75 -13
- data/COPYING +0 -340
- data/examples/example.ec +0 -24
data/lib/erubis/tiny.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.0
|
2
|
+
## $Rev: 35 $
|
3
|
+
## $Release: 2.1.0 $
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -17,16 +17,21 @@ module Erubis
|
|
17
17
|
##
|
18
18
|
class TinyEruby
|
19
19
|
|
20
|
-
def initialize(input)
|
21
|
-
@src =
|
20
|
+
def initialize(input=nil)
|
21
|
+
@src = convert(input) if input
|
22
22
|
end
|
23
23
|
attr_reader :src
|
24
24
|
|
25
|
-
EMBEDDED_PATTERN =
|
25
|
+
EMBEDDED_PATTERN = /<%(=+|\#)?(.*?)-?%>/m
|
26
26
|
|
27
|
-
def
|
27
|
+
def convert(input)
|
28
28
|
src = "_buf = [];" # preamble
|
29
|
-
|
29
|
+
pos = 0
|
30
|
+
input.scan(EMBEDDED_PATTERN) do |indicator, code|
|
31
|
+
match = Regexp.last_match
|
32
|
+
index = match.begin(0)
|
33
|
+
text = input[pos, index - pos]
|
34
|
+
pos = match.end(0)
|
30
35
|
src << " _buf << '" << escape_text(text) << "';"
|
31
36
|
if !indicator # <% %>
|
32
37
|
src << code << ";"
|
@@ -62,4 +67,73 @@ module Erubis
|
|
62
67
|
|
63
68
|
end
|
64
69
|
|
70
|
+
|
71
|
+
|
72
|
+
module PI
|
73
|
+
end
|
74
|
+
|
75
|
+
class PI::TinyEruby
|
76
|
+
|
77
|
+
def initialize(input=nil, options={})
|
78
|
+
@escape = options[:escape] || 'Erubis::XmlHelper.escape_xml'
|
79
|
+
@src = convert(input) if input
|
80
|
+
end
|
81
|
+
|
82
|
+
attr_reader :src
|
83
|
+
|
84
|
+
EMBEDDED_PATTERN = /(^[ \t]*)?<\?rb(\s.*?)\?>([ \t]*\r?\n)?|\$(!*)?\{(.*?)\}/
|
85
|
+
|
86
|
+
def convert(input)
|
87
|
+
src = "_buf = [];" # preamble
|
88
|
+
pos = 0
|
89
|
+
input.scan(EMBEDDED_PATTERN) do |lspace, stmtcode, rspace, indicator, exprcode|
|
90
|
+
match = Regexp.last_match
|
91
|
+
index = match.begin(0)
|
92
|
+
text = input[pos, index - pos]
|
93
|
+
pos = match.end(0)
|
94
|
+
if stmtcode # <?rb ... ?>
|
95
|
+
code = stmtcode
|
96
|
+
src << " _buf << '" << escape_text(text) << "';"
|
97
|
+
if lspace && rspace
|
98
|
+
src << "#{lspace}#{code}#{rspace}"
|
99
|
+
else
|
100
|
+
src << " _buf << '#{lspace}';" if lspace
|
101
|
+
src << code << ";"
|
102
|
+
src << " _buf << '#{rspace}';" if rspace
|
103
|
+
end
|
104
|
+
else # ${...}, $!{...}
|
105
|
+
code = exprcode
|
106
|
+
if indicator.nil? || indicator.empty?
|
107
|
+
src << " _buf << #{@escape}(" << code << ");"
|
108
|
+
elsif indicator == '!'
|
109
|
+
src << " _buf << (" << code << ").to_s;"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
rest = $' || input
|
114
|
+
src << " _buf << '" << escape_text(rest) << "';"
|
115
|
+
src << "\n_buf.join\n" # postamble
|
116
|
+
return src
|
117
|
+
end
|
118
|
+
|
119
|
+
def escape_text(text)
|
120
|
+
return text.gsub!(/['\\]/, '\\\\\&') || text
|
121
|
+
end
|
122
|
+
|
123
|
+
def result(binding=TOPLEVEL_BINDING)
|
124
|
+
eval @src, binding
|
125
|
+
end
|
126
|
+
|
127
|
+
def evaluate(context=Object.new)
|
128
|
+
if context.is_a?(Hash)
|
129
|
+
obj = Object.new
|
130
|
+
context.each do |k, v| obj.instance_variable_set("@#{k}", v) end
|
131
|
+
context = obj
|
132
|
+
end
|
133
|
+
context.instance_eval @src
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
|
65
139
|
end
|
data/test/assert-text-equal.rb
CHANGED
data/test/test-engines.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.0
|
2
|
+
## $Rev: 40 $
|
3
|
+
## $Release: 2.1.0 $
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -17,10 +17,9 @@ require 'erubis/engine/ejavascript'
|
|
17
17
|
|
18
18
|
|
19
19
|
class EnginesTest < Test::Unit::TestCase
|
20
|
-
extend TestEnhancer
|
21
20
|
|
22
21
|
#load_yaml_documents(__FILE__)
|
23
|
-
testdata_list =
|
22
|
+
testdata_list = load_yaml_datafile(__FILE__)
|
24
23
|
define_testmethods(testdata_list)
|
25
24
|
|
26
25
|
def _test()
|
@@ -76,7 +75,7 @@ __END__
|
|
76
75
|
<%
|
77
76
|
$i = 0;
|
78
77
|
foreach ($list as $item) {
|
79
|
-
|
78
|
+
$i++;
|
80
79
|
%>
|
81
80
|
<tr>
|
82
81
|
<td><%= $i %></td>
|
@@ -117,7 +116,7 @@ __END__
|
|
117
116
|
<% for (i = 0; i < list; i++) { %>
|
118
117
|
<tr>
|
119
118
|
<td><%= "%d", i %></td>
|
120
|
-
<td><%==
|
119
|
+
<td><%== list[i] %></td>
|
121
120
|
</tr>
|
122
121
|
<% } %>
|
123
122
|
</tbody>
|
@@ -130,7 +129,7 @@ __END__
|
|
130
129
|
for (i = 0; i < list; i++) {
|
131
130
|
fputs(" <tr>\n"
|
132
131
|
" <td>", stdout); fprintf(stdout, "%d", i); fputs("</td>\n"
|
133
|
-
" <td>", stdout);
|
132
|
+
" <td>", stdout); escape(list[i], stdout); fputs("</td>\n"
|
134
133
|
" </tr>\n", stdout);
|
135
134
|
}
|
136
135
|
fputs(" </tbody>\n"
|
@@ -280,7 +279,7 @@ __END__
|
|
280
279
|
</table>
|
281
280
|
<%=== $i %>
|
282
281
|
expected: |4
|
283
|
-
|
282
|
+
use HTML::Entities;
|
284
283
|
my $user = 'Erubis';
|
285
284
|
my @list = ('<aaa>', 'b&b', '"ccc"');
|
286
285
|
|
@@ -291,7 +290,7 @@ __END__
|
|
291
290
|
for $item (@list) {
|
292
291
|
print(' <tr bgcolor='); print(++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); print('">
|
293
292
|
<td>'); print($i); print('</td>
|
294
|
-
<td>'); print(
|
293
|
+
<td>'); print(encode_entities($item)); print('</td>
|
295
294
|
</tr>
|
296
295
|
'); }
|
297
296
|
print(' </tbody>
|
data/test/test-erubis.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.0
|
2
|
+
## $Rev: 37 $
|
3
|
+
## $Release: 2.1.0 $
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -15,16 +15,21 @@ require 'erubis/tiny'
|
|
15
15
|
|
16
16
|
|
17
17
|
class ErubisTest < Test::Unit::TestCase
|
18
|
-
extend TestEnhancer
|
19
18
|
|
20
|
-
testdata_list =
|
19
|
+
testdata_list = load_yaml_datafile(__FILE__)
|
21
20
|
define_testmethods(testdata_list)
|
22
21
|
|
23
22
|
|
24
23
|
def _test()
|
25
24
|
@src.gsub!(/\^/, ' ')
|
26
25
|
@output.gsub!(/\^/, ' ') if @output.is_a?(String)
|
27
|
-
|
26
|
+
if @class
|
27
|
+
k = Erubis
|
28
|
+
@class.split('::').each do |name| k = k.const_get(name) end
|
29
|
+
@klass = k
|
30
|
+
else
|
31
|
+
@klass = Erubis::Eruby
|
32
|
+
end
|
28
33
|
@options ||= {}
|
29
34
|
@chomp.each do |target|
|
30
35
|
case target
|
@@ -53,14 +58,14 @@ class ErubisTest < Test::Unit::TestCase
|
|
53
58
|
end
|
54
59
|
assert_text_equal(@src, eruby.src)
|
55
60
|
|
56
|
-
return if @testopt == '
|
61
|
+
return if @testopt == 'skip_output'
|
57
62
|
|
58
63
|
list = ['<aaa>', 'b&b', '"ccc"']
|
59
64
|
context = @testopt == 'context' ? Erubis::Context.new : {}
|
60
65
|
context[:list] = list
|
61
66
|
|
62
67
|
case @testopt
|
63
|
-
when/\Aeval\(/
|
68
|
+
when /\Aeval\(/
|
64
69
|
eval eruby.src
|
65
70
|
actual = eval @testopt
|
66
71
|
assert_text_equal(@output, actual)
|
@@ -109,12 +114,13 @@ __END__
|
|
109
114
|
_buf << '</ul>
|
110
115
|
';
|
111
116
|
_buf.join
|
112
|
-
output: &
|
117
|
+
output: &basic1_output|
|
113
118
|
<ul>
|
114
119
|
<li><aaa></li>
|
115
120
|
<li>b&b</li>
|
116
121
|
<li>"ccc"</li>
|
117
122
|
</ul>
|
123
|
+
|
118
124
|
##
|
119
125
|
- name: basic2
|
120
126
|
input: |
|
@@ -137,12 +143,13 @@ __END__
|
|
137
143
|
_buf << '</ul>
|
138
144
|
';
|
139
145
|
_buf.join
|
140
|
-
output: *
|
146
|
+
output: *basic1_output
|
141
147
|
# <ul>
|
142
148
|
# <li><aaa></li>
|
143
149
|
# <li>b&b</li>
|
144
150
|
# <li>"ccc"</li>
|
145
151
|
# </ul>
|
152
|
+
|
146
153
|
##
|
147
154
|
- name: basic3
|
148
155
|
input: |
|
@@ -160,6 +167,7 @@ __END__
|
|
160
167
|
output: |
|
161
168
|
<ul><li><aaa></li><li>b&b</li><li>"ccc"</li>
|
162
169
|
</ul>
|
170
|
+
|
163
171
|
##
|
164
172
|
- name: context1
|
165
173
|
testopt: context
|
@@ -177,7 +185,8 @@ __END__
|
|
177
185
|
_buf << '</ul>
|
178
186
|
';
|
179
187
|
_buf.join
|
180
|
-
output: *
|
188
|
+
output: *basic1_output
|
189
|
+
|
181
190
|
##
|
182
191
|
- name: ignore1
|
183
192
|
input: |
|
@@ -210,6 +219,7 @@ __END__
|
|
210
219
|
<li> : b&b </li>
|
211
220
|
<li> : "ccc" </li>
|
212
221
|
</ul>
|
222
|
+
|
213
223
|
##
|
214
224
|
- name: quotation1
|
215
225
|
desc: single quotation and backslash
|
@@ -225,6 +235,7 @@ __END__
|
|
225
235
|
';
|
226
236
|
_buf.join
|
227
237
|
output: *quotation1_input
|
238
|
+
|
228
239
|
##
|
229
240
|
- name: pattern1
|
230
241
|
options:
|
@@ -243,12 +254,13 @@ __END__
|
|
243
254
|
_buf << '</ul>
|
244
255
|
';
|
245
256
|
_buf.join
|
246
|
-
output: *
|
257
|
+
output: *basic1_output
|
247
258
|
# <ul>
|
248
259
|
# <li><aaa></li>
|
249
260
|
# <li>b&b</li>
|
250
261
|
# <li>"ccc"</li>
|
251
262
|
# </ul>
|
263
|
+
|
252
264
|
##
|
253
265
|
- name: pattern2
|
254
266
|
options:
|
@@ -267,12 +279,13 @@ __END__
|
|
267
279
|
_buf << '</ul>
|
268
280
|
';
|
269
281
|
_buf.join
|
270
|
-
output: *
|
282
|
+
output: *basic1_output
|
271
283
|
# <ul>
|
272
284
|
# <li><aaa></li>
|
273
285
|
# <li>b&b</li>
|
274
286
|
# <li>"ccc"</li>
|
275
287
|
# </ul>
|
288
|
+
|
276
289
|
##
|
277
290
|
- name: trim1
|
278
291
|
options:
|
@@ -301,9 +314,10 @@ __END__
|
|
301
314
|
<li>"ccc"</li>
|
302
315
|
^
|
303
316
|
</ul>
|
317
|
+
|
304
318
|
##
|
305
319
|
- name: bodyonly1
|
306
|
-
testopt:
|
320
|
+
testopt: skip_output
|
307
321
|
options: { :preamble: no, :postamble: no }
|
308
322
|
input: *basic1_input
|
309
323
|
src: |4
|
@@ -315,6 +329,7 @@ __END__
|
|
315
329
|
';
|
316
330
|
chomp: [src]
|
317
331
|
expected: null
|
332
|
+
|
318
333
|
##
|
319
334
|
- name: loadfile1
|
320
335
|
testopt: load_file
|
@@ -344,6 +359,7 @@ __END__
|
|
344
359
|
output:
|
345
360
|
"<ul>\n <li><aaa></li>\n <li>b&b</li>\n <li>\"ccc\"</li>\n</ul>\n"
|
346
361
|
# "<ul>\r\n <li><aaa></li>\r\n <li>b&b</li>\r\n <li>\"ccc\"</li>\r\n</ul>\r\n"
|
362
|
+
|
347
363
|
##
|
348
364
|
- name: nomatch1
|
349
365
|
desc: bug
|
@@ -358,6 +374,24 @@ __END__
|
|
358
374
|
';
|
359
375
|
_buf.join
|
360
376
|
output: *nomatch1
|
377
|
+
|
378
|
+
##
|
379
|
+
- name: escape1
|
380
|
+
options: { :escape: true }
|
381
|
+
input: |
|
382
|
+
<% str = '<>&"' %>
|
383
|
+
<%= str %>
|
384
|
+
<%== str %>
|
385
|
+
src: |
|
386
|
+
_buf = []; str = '<>&"'
|
387
|
+
_buf << Erubis::XmlHelper.escape_xml( str ); _buf << '
|
388
|
+
'; _buf << ( str ).to_s; _buf << '
|
389
|
+
';
|
390
|
+
_buf.join
|
391
|
+
output: |
|
392
|
+
<>&"
|
393
|
+
<>&"
|
394
|
+
|
361
395
|
##
|
362
396
|
- name: xml1
|
363
397
|
class: XmlEruby
|
@@ -386,10 +420,11 @@ __END__
|
|
386
420
|
"ccc"
|
387
421
|
"ccc"
|
388
422
|
</pre>
|
423
|
+
|
389
424
|
##
|
390
425
|
- name: xml2
|
391
426
|
class: XmlEruby
|
392
|
-
testopt:
|
427
|
+
testopt: skip_output
|
393
428
|
input: |
|
394
429
|
<% for item in list %>
|
395
430
|
<%= item["var#{n}"] %>
|
@@ -406,6 +441,7 @@ __END__
|
|
406
441
|
'; end
|
407
442
|
_buf.join
|
408
443
|
output: |
|
444
|
+
|
409
445
|
##
|
410
446
|
- name: printout1
|
411
447
|
class: PrintOutEruby
|
@@ -418,7 +454,8 @@ __END__
|
|
418
454
|
'; end
|
419
455
|
print '</ul>
|
420
456
|
';
|
421
|
-
output: *
|
457
|
+
output: *basic1_output
|
458
|
+
|
422
459
|
##
|
423
460
|
- name: printenabled1
|
424
461
|
class: PrintEnabledEruby
|
@@ -436,12 +473,13 @@ __END__
|
|
436
473
|
_buf << '</ul>
|
437
474
|
';
|
438
475
|
_buf.join
|
439
|
-
output: *
|
476
|
+
output: *basic1_output
|
440
477
|
# <ul>
|
441
478
|
# <li><aaa></li>
|
442
479
|
# <li>b&b</li>
|
443
480
|
# <li>"ccc"</li>
|
444
481
|
# </ul>
|
482
|
+
|
445
483
|
##
|
446
484
|
- name: stdout1
|
447
485
|
class: StdoutEruby
|
@@ -460,12 +498,13 @@ __END__
|
|
460
498
|
_buf << '</ul>
|
461
499
|
';
|
462
500
|
''
|
463
|
-
output: *
|
501
|
+
output: *basic1_output
|
464
502
|
# <ul>
|
465
503
|
# <li><aaa></li>
|
466
504
|
# <li>b&b</li>
|
467
505
|
# <li>"ccc"</li>
|
468
506
|
# </ul>
|
507
|
+
|
469
508
|
##
|
470
509
|
- name: array1
|
471
510
|
class: ArrayEruby
|
@@ -495,6 +534,7 @@ __END__
|
|
495
534
|
- "\"ccc\""
|
496
535
|
- "</li>\n"
|
497
536
|
- "</ul>\n"
|
537
|
+
|
498
538
|
##
|
499
539
|
- name: stringbuffer1
|
500
540
|
class: StringBufferEruby
|
@@ -512,12 +552,13 @@ __END__
|
|
512
552
|
_buf << '</ul>
|
513
553
|
';
|
514
554
|
_buf
|
515
|
-
output: *
|
555
|
+
output: *basic1_output
|
516
556
|
# <ul>
|
517
557
|
# <li><aaa></li>
|
518
558
|
# <li>b&b</li>
|
519
559
|
# <li>"ccc"</li>
|
520
560
|
# </ul>
|
561
|
+
|
521
562
|
##
|
522
563
|
- name: notext1
|
523
564
|
class: NoTextEruby
|
@@ -530,6 +571,20 @@ __END__
|
|
530
571
|
|
531
572
|
_buf.join
|
532
573
|
output: '<aaa>b&b"ccc"'
|
574
|
+
|
575
|
+
##
|
576
|
+
- name: nocode1
|
577
|
+
class: NoCodeEruby
|
578
|
+
testopt: skip_output
|
579
|
+
input: *basic1_input
|
580
|
+
src: |
|
581
|
+
<ul>
|
582
|
+
|
583
|
+
<li></li>
|
584
|
+
|
585
|
+
</ul>
|
586
|
+
output:
|
587
|
+
|
533
588
|
##
|
534
589
|
- name: simplified
|
535
590
|
class: SimplifiedEruby
|
@@ -567,6 +622,7 @@ __END__
|
|
567
622
|
</li>
|
568
623
|
^
|
569
624
|
</ul>
|
625
|
+
|
570
626
|
##
|
571
627
|
- name: bipattern1
|
572
628
|
class: BiPatternEruby
|
@@ -589,6 +645,7 @@ __END__
|
|
589
645
|
b&b = b&b
|
590
646
|
"ccc" % "ccc"
|
591
647
|
"ccc" = "ccc"
|
648
|
+
|
592
649
|
##
|
593
650
|
- name: bipattern2
|
594
651
|
class: BiPatternEruby
|
@@ -611,6 +668,7 @@ __END__
|
|
611
668
|
b&b = b&b
|
612
669
|
"ccc" % "ccc"
|
613
670
|
"ccc" = "ccc"
|
671
|
+
|
614
672
|
##
|
615
673
|
- name: percentline1
|
616
674
|
class: PercentLineEruby
|
@@ -662,6 +720,7 @@ __END__
|
|
662
720
|
% double percent
|
663
721
|
% spaced percent
|
664
722
|
</pre>
|
723
|
+
|
665
724
|
##
|
666
725
|
- name: headerfooter1
|
667
726
|
class: HeaderFooterEruby
|
@@ -695,6 +754,7 @@ __END__
|
|
695
754
|
<li>b&b</li>
|
696
755
|
<li>"ccc"</li>
|
697
756
|
</ol>
|
757
|
+
|
698
758
|
##
|
699
759
|
- name: optimized1
|
700
760
|
class: OptimizedEruby
|
@@ -736,6 +796,7 @@ __END__
|
|
736
796
|
</tr>
|
737
797
|
</table>
|
738
798
|
<ul><li><aaa></li><li>b&b</li><li>"ccc"</li></ul>
|
799
|
+
|
739
800
|
##
|
740
801
|
- name: optimized2
|
741
802
|
class: OptimizedXmlEruby
|
@@ -777,6 +838,7 @@ __END__
|
|
777
838
|
</tr>
|
778
839
|
</table>
|
779
840
|
<ul><li><aaa></li><li>b&b</li><li>"ccc"</li></ul>
|
841
|
+
|
780
842
|
##
|
781
843
|
- name: optimized3
|
782
844
|
desc: bug
|
@@ -798,6 +860,7 @@ __END__
|
|
798
860
|
<aaa>
|
799
861
|
b&b
|
800
862
|
"ccc"
|
863
|
+
|
801
864
|
##
|
802
865
|
- name: optimized4
|
803
866
|
desc: single quotation and backslash
|
@@ -813,6 +876,7 @@ __END__
|
|
813
876
|
';
|
814
877
|
_buf
|
815
878
|
output: *optimized4_input
|
879
|
+
|
816
880
|
##
|
817
881
|
- name: tiny1
|
818
882
|
class: TinyEruby
|
@@ -841,6 +905,7 @@ __END__
|
|
841
905
|
<li>"ccc"</li>
|
842
906
|
^
|
843
907
|
</ul>
|
908
|
+
|
844
909
|
##
|
845
910
|
- name: tiny2
|
846
911
|
class: TinyEruby
|
@@ -869,4 +934,117 @@ __END__
|
|
869
934
|
<li>"ccc"</li>
|
870
935
|
^
|
871
936
|
</ul>
|
937
|
+
|
938
|
+
##
|
939
|
+
- name: pi1
|
940
|
+
class: PI::Eruby
|
941
|
+
testopt: evaluate
|
942
|
+
input: &input_pi1|
|
943
|
+
<ul>
|
944
|
+
<?rb for item in @list ?>
|
945
|
+
<li>@{item}@ / @!{item}@</li>
|
946
|
+
<li><%= item %> / <%== item %></li>
|
947
|
+
<?rb end ?>
|
948
|
+
</ul>
|
949
|
+
src: &src_pi1|
|
950
|
+
_buf = []; _buf << '<ul>
|
951
|
+
'; for item in @list
|
952
|
+
_buf << ' <li>'; _buf << Erubis::XmlHelper.escape_xml(item); _buf << ' / '; _buf << (item).to_s; _buf << '</li>
|
953
|
+
<li>'; _buf << ( item ).to_s; _buf << ' / '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</li>
|
954
|
+
'; end
|
955
|
+
_buf << '</ul>
|
956
|
+
';
|
957
|
+
_buf.join
|
958
|
+
output: &output_pi1|
|
959
|
+
<ul>
|
960
|
+
<li><aaa> / <aaa></li>
|
961
|
+
<li><aaa> / <aaa></li>
|
962
|
+
<li>b&b / b&b</li>
|
963
|
+
<li>b&b / b&b</li>
|
964
|
+
<li>"ccc" / "ccc"</li>
|
965
|
+
<li>"ccc" / "ccc"</li>
|
966
|
+
</ul>
|
967
|
+
|
872
968
|
##
|
969
|
+
- name: pi2
|
970
|
+
class: PI::Eruby
|
971
|
+
options: { :escape: false }
|
972
|
+
testopt: evaluate
|
973
|
+
input: *input_pi1
|
974
|
+
src: |
|
975
|
+
_buf = []; _buf << '<ul>
|
976
|
+
'; for item in @list
|
977
|
+
_buf << ' <li>'; _buf << (item).to_s; _buf << ' / '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '</li>
|
978
|
+
<li>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << ' / '; _buf << ( item ).to_s; _buf << '</li>
|
979
|
+
'; end
|
980
|
+
_buf << '</ul>
|
981
|
+
';
|
982
|
+
_buf.join
|
983
|
+
output: |
|
984
|
+
<ul>
|
985
|
+
<li><aaa> / <aaa></li>
|
986
|
+
<li><aaa> / <aaa></li>
|
987
|
+
<li>b&b / b&b</li>
|
988
|
+
<li>b&b / b&b</li>
|
989
|
+
<li>"ccc" / "ccc"</li>
|
990
|
+
<li>"ccc" / "ccc"</li>
|
991
|
+
</ul>
|
992
|
+
|
993
|
+
##
|
994
|
+
- name: pi3
|
995
|
+
class: PI::Eruby
|
996
|
+
options: { :pi: hoge, :embchar: '$' }
|
997
|
+
testopt: evaluate
|
998
|
+
input: |
|
999
|
+
<ul>
|
1000
|
+
<?hoge for item in @list ?>
|
1001
|
+
<li>${item}$ / $!{item}$</li>
|
1002
|
+
<li><%= item %> / <%== item %></li>
|
1003
|
+
<?hoge end ?>
|
1004
|
+
</ul>
|
1005
|
+
src: *src_pi1
|
1006
|
+
output: *output_pi1
|
1007
|
+
|
1008
|
+
- name: pi4
|
1009
|
+
class: PI::Eruby
|
1010
|
+
testopt: evaluate
|
1011
|
+
input: |
|
1012
|
+
<?rb-header
|
1013
|
+
def show(list)
|
1014
|
+
?>
|
1015
|
+
<ul>
|
1016
|
+
<?rb for item in list ?>
|
1017
|
+
<?rb-value item ?>
|
1018
|
+
<?rb end ?>
|
1019
|
+
<?rb-comment
|
1020
|
+
# comment
|
1021
|
+
# comment
|
1022
|
+
?>
|
1023
|
+
</ul>
|
1024
|
+
<?rb-footer
|
1025
|
+
end
|
1026
|
+
show(@list) ?>
|
1027
|
+
|
1028
|
+
src: |4
|
1029
|
+
|
1030
|
+
def show(list)
|
1031
|
+
|
1032
|
+
_buf = []; _buf << '<ul>
|
1033
|
+
'; for item in list
|
1034
|
+
_buf << ( item
|
1035
|
+
).to_s; end
|
1036
|
+
|
1037
|
+
|
1038
|
+
|
1039
|
+
|
1040
|
+
_buf << '</ul>
|
1041
|
+
';
|
1042
|
+
_buf.join
|
1043
|
+
|
1044
|
+
end
|
1045
|
+
show(@list)
|
1046
|
+
|
1047
|
+
output: |
|
1048
|
+
<ul>
|
1049
|
+
<aaa>b&b"ccc"</ul>
|
1050
|
+
|