erbse 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +3 -0
- data/Gemfile +3 -0
- data/README.md +40 -22
- data/Rakefile +13 -0
- data/lib/erbse.rb +3 -6
- data/lib/erbse/converter.rb +41 -241
- data/lib/erbse/eruby.rb +114 -0
- data/lib/erbse/template.rb +14 -0
- data/lib/erbse/version.rb +1 -1
- data/test/erbse_test.rb +14 -0
- data/test/test_helper.rb +2 -0
- metadata +9 -149
- data/CHANGES.txt +0 -828
- data/bin/erubis +0 -10
- data/lib/erbse/context.rb +0 -83
- data/lib/erbse/engine.rb +0 -114
- data/lib/erbse/engine/ec.rb +0 -117
- data/lib/erbse/engine/ecpp.rb +0 -113
- data/lib/erbse/engine/ejava.rb +0 -110
- data/lib/erbse/engine/ejavascript.rb +0 -119
- data/lib/erbse/engine/enhanced.rb +0 -126
- data/lib/erbse/engine/eperl.rb +0 -95
- data/lib/erbse/engine/ephp.rb +0 -99
- data/lib/erbse/engine/eruby.rb +0 -119
- data/lib/erbse/engine/escheme.rb +0 -114
- data/lib/erbse/engine/optimized.rb +0 -127
- data/lib/erbse/enhancer.rb +0 -723
- data/lib/erbse/error.rb +0 -23
- data/lib/erbse/evaluator.rb +0 -88
- data/lib/erbse/generator.rb +0 -85
- data/lib/erbse/helper.rb +0 -47
- data/lib/erbse/helpers/rails_form_helper.rb +0 -197
- data/lib/erbse/helpers/rails_helper.rb +0 -353
- data/lib/erbse/main.rb +0 -516
- data/lib/erbse/preprocessing.rb +0 -58
- data/lib/erbse/tiny.rb +0 -144
- data/lib/erbse/util.rb +0 -22
- data/test/assert-text-equal.rb +0 -44
- data/test/data/users-guide/Example.ejava +0 -55
- data/test/data/users-guide/array_example.result +0 -9
- data/test/data/users-guide/arraybuffer_example.result +0 -9
- data/test/data/users-guide/bipattern-example.rhtml +0 -4
- data/test/data/users-guide/bipattern_example.result +0 -6
- data/test/data/users-guide/bufvar-example.rb +0 -10
- data/test/data/users-guide/bufvar-example.result +0 -17
- data/test/data/users-guide/context.rb +0 -6
- data/test/data/users-guide/context.yaml +0 -8
- data/test/data/users-guide/def_method.rb +0 -14
- data/test/data/users-guide/def_method.result +0 -3
- data/test/data/users-guide/escape_example.result +0 -9
- data/test/data/users-guide/example.ec +0 -27
- data/test/data/users-guide/example.ecpp +0 -30
- data/test/data/users-guide/example.ejs +0 -20
- data/test/data/users-guide/example.eperl +0 -18
- data/test/data/users-guide/example.ephp +0 -18
- data/test/data/users-guide/example.eruby +0 -6
- data/test/data/users-guide/example.escheme +0 -28
- data/test/data/users-guide/example1.eruby +0 -6
- data/test/data/users-guide/example1.rb +0 -17
- data/test/data/users-guide/example1.result +0 -16
- data/test/data/users-guide/example10.rb +0 -4
- data/test/data/users-guide/example10.result +0 -17
- data/test/data/users-guide/example10.xhtml +0 -14
- data/test/data/users-guide/example10_x.result +0 -17
- data/test/data/users-guide/example11.php +0 -20
- data/test/data/users-guide/example11.result +0 -23
- data/test/data/users-guide/example11.rhtml +0 -21
- data/test/data/users-guide/example11_C.result +0 -10
- data/test/data/users-guide/example11_N.result +0 -16
- data/test/data/users-guide/example11_U.result +0 -16
- data/test/data/users-guide/example11_php.result +0 -15
- data/test/data/users-guide/example1_x.result +0 -9
- data/test/data/users-guide/example2.eruby +0 -7
- data/test/data/users-guide/example2.rb +0 -10
- data/test/data/users-guide/example2.result +0 -27
- data/test/data/users-guide/example2_trim.result +0 -10
- data/test/data/users-guide/example2_x.result +0 -10
- data/test/data/users-guide/example3.eruby +0 -6
- data/test/data/users-guide/example3.rb +0 -10
- data/test/data/users-guide/example31.result +0 -22
- data/test/data/users-guide/example32.result +0 -4
- data/test/data/users-guide/example3_e.result +0 -8
- data/test/data/users-guide/example4.eruby +0 -3
- data/test/data/users-guide/example4.rb +0 -11
- data/test/data/users-guide/example4.result +0 -10
- data/test/data/users-guide/example4_x.result +0 -5
- data/test/data/users-guide/example5.eruby +0 -6
- data/test/data/users-guide/example5.rb +0 -16
- data/test/data/users-guide/example5.result +0 -7
- data/test/data/users-guide/example6.rb +0 -12
- data/test/data/users-guide/example6.result +0 -7
- data/test/data/users-guide/example7.eruby +0 -8
- data/test/data/users-guide/example71.result +0 -13
- data/test/data/users-guide/example72.result +0 -13
- data/test/data/users-guide/example8.eruby +0 -6
- data/test/data/users-guide/example8_ruby.result +0 -7
- data/test/data/users-guide/example8_yaml.result +0 -7
- data/test/data/users-guide/example9.eruby +0 -3
- data/test/data/users-guide/example9.rb +0 -8
- data/test/data/users-guide/example9.result +0 -9
- data/test/data/users-guide/example91.result +0 -5
- data/test/data/users-guide/example92.result +0 -4
- data/test/data/users-guide/example_c.result +0 -32
- data/test/data/users-guide/example_java.result +0 -56
- data/test/data/users-guide/example_js.result +0 -22
- data/test/data/users-guide/example_perl.result +0 -20
- data/test/data/users-guide/example_php.result +0 -19
- data/test/data/users-guide/example_scheme.result +0 -30
- data/test/data/users-guide/example_scheme_display.result +0 -29
- data/test/data/users-guide/fasteruby-example.rb +0 -8
- data/test/data/users-guide/fasteruby-example.result +0 -18
- data/test/data/users-guide/fasteruby.rb +0 -11
- data/test/data/users-guide/fasteruby.result +0 -38
- data/test/data/users-guide/fasteruby.rhtml +0 -15
- data/test/data/users-guide/headerfooter-example.eruby +0 -9
- data/test/data/users-guide/headerfooter-example2.rb +0 -8
- data/test/data/users-guide/headerfooter-example2.rhtml +0 -10
- data/test/data/users-guide/headerfooter_example.result +0 -11
- data/test/data/users-guide/headerfooter_example2.result +0 -13
- data/test/data/users-guide/interpolation_example.result +0 -9
- data/test/data/users-guide/main_program1.rb +0 -8
- data/test/data/users-guide/main_program1.result +0 -6
- data/test/data/users-guide/main_program2.rb +0 -8
- data/test/data/users-guide/main_program2.result +0 -6
- data/test/data/users-guide/nocode-example.eruby +0 -14
- data/test/data/users-guide/nocode-php.result +0 -20
- data/test/data/users-guide/nocode_example.result +0 -15
- data/test/data/users-guide/normal-eruby-test.eruby +0 -9
- data/test/data/users-guide/normal_eruby_test.result +0 -11
- data/test/data/users-guide/notext-example.eruby +0 -14
- data/test/data/users-guide/notext-example.php +0 -19
- data/test/data/users-guide/notext-php.result +0 -20
- data/test/data/users-guide/notext_example.result +0 -16
- data/test/data/users-guide/percentline-example.rhtml +0 -6
- data/test/data/users-guide/percentline_example.result +0 -9
- data/test/data/users-guide/prefixedline-example.rb +0 -9
- data/test/data/users-guide/prefixedline-example.rhtml +0 -6
- data/test/data/users-guide/prefixedline_example.result +0 -9
- data/test/data/users-guide/printenable_example.result +0 -4
- data/test/data/users-guide/printenabled-example.eruby +0 -3
- data/test/data/users-guide/printenabled-example.rb +0 -8
- data/test/data/users-guide/printstatement_example.result +0 -8
- data/test/data/users-guide/simplify_example.result +0 -9
- data/test/data/users-guide/stderr.log +0 -3
- data/test/data/users-guide/stdout_exmple.result +0 -9
- data/test/data/users-guide/stringbuffer_example.result +0 -9
- data/test/data/users-guide/tail_260.result +0 -4
- data/test/data/users-guide/tailnewline.rhtml +0 -3
- data/test/data/users-guide/template1.rhtml +0 -4
- data/test/data/users-guide/template2.rhtml +0 -4
- data/test/test-engines.rb +0 -425
- data/test/test-enhancers.rb +0 -646
- data/test/test-erubis.rb +0 -887
- data/test/test-index-cgi.rb +0 -191
- data/test/test-main.rb +0 -752
- data/test/test-users-guide.rb +0 -73
- data/test/test.rb +0 -45
- data/test/testutil.rb +0 -111
data/test/test-engines.rb
DELETED
@@ -1,425 +0,0 @@
|
|
1
|
-
##
|
2
|
-
## $Release: 2.7.0 $
|
3
|
-
## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
|
4
|
-
##
|
5
|
-
|
6
|
-
require "#{File.dirname(__FILE__)}/test.rb"
|
7
|
-
|
8
|
-
require 'erubis'
|
9
|
-
require 'erubis/engine/eruby'
|
10
|
-
require 'erubis/engine/ephp'
|
11
|
-
require 'erubis/engine/ec'
|
12
|
-
require 'erubis/engine/ecpp'
|
13
|
-
require 'erubis/engine/ejava'
|
14
|
-
require 'erubis/engine/escheme'
|
15
|
-
require 'erubis/engine/eperl'
|
16
|
-
require 'erubis/engine/ejavascript'
|
17
|
-
|
18
|
-
|
19
|
-
class EnginesTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
#load_yaml_documents(__FILE__)
|
22
|
-
testdata_list = load_yaml_datafile(__FILE__)
|
23
|
-
define_testmethods(testdata_list)
|
24
|
-
|
25
|
-
def _test()
|
26
|
-
klass = Erubis.const_get(@class)
|
27
|
-
engine = klass.new(@input, @options || {})
|
28
|
-
actual = engine.src
|
29
|
-
assert_text_equal(@expected, actual)
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
self.post_definition()
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
__END__
|
38
|
-
- name: ruby1
|
39
|
-
lang: ruby
|
40
|
-
class: Eruby
|
41
|
-
options:
|
42
|
-
input: |
|
43
|
-
<table>
|
44
|
-
<tbody>
|
45
|
-
<% i = 0
|
46
|
-
list.each_with_index do |item, i| %>
|
47
|
-
<tr>
|
48
|
-
<td><%= i+1 %></td>
|
49
|
-
<td><%== list %></td>
|
50
|
-
</tr>
|
51
|
-
<% end %>
|
52
|
-
</tbody>
|
53
|
-
</table>
|
54
|
-
<%=== i+1 %>
|
55
|
-
expected: |
|
56
|
-
_buf = ''; _buf << '<table>
|
57
|
-
<tbody>
|
58
|
-
'; i = 0
|
59
|
-
list.each_with_index do |item, i|
|
60
|
-
_buf << ' <tr>
|
61
|
-
<td>'; _buf << ( i+1 ).to_s; _buf << '</td>
|
62
|
-
<td>'; _buf << Erubis::XmlHelper.escape_xml( list ); _buf << '</td>
|
63
|
-
</tr>
|
64
|
-
'; end
|
65
|
-
_buf << ' </tbody>
|
66
|
-
</table>
|
67
|
-
'; $stderr.puts("*** debug: i+1=#{(i+1).inspect}"); _buf << '
|
68
|
-
';
|
69
|
-
_buf.to_s
|
70
|
-
##
|
71
|
-
- name: ruby2_options
|
72
|
-
lang: ruby
|
73
|
-
class: Eruby
|
74
|
-
options: { :bufvar: '@_out_buf' }
|
75
|
-
input: |
|
76
|
-
<table>
|
77
|
-
<% for item in @items %>
|
78
|
-
<tr>
|
79
|
-
<td><%= i+1 %></td>
|
80
|
-
<td><%== list %></td>
|
81
|
-
</tr>
|
82
|
-
<% end %>
|
83
|
-
</table>
|
84
|
-
expected: |
|
85
|
-
@_out_buf = ''; @_out_buf << '<table>
|
86
|
-
'; for item in @items
|
87
|
-
@_out_buf << ' <tr>
|
88
|
-
<td>'; @_out_buf << ( i+1 ).to_s; @_out_buf << '</td>
|
89
|
-
<td>'; @_out_buf << Erubis::XmlHelper.escape_xml( list ); @_out_buf << '</td>
|
90
|
-
</tr>
|
91
|
-
'; end
|
92
|
-
@_out_buf << '</table>
|
93
|
-
';
|
94
|
-
@_out_buf.to_s
|
95
|
-
##
|
96
|
-
- name: php1
|
97
|
-
lang: php
|
98
|
-
class: Ephp
|
99
|
-
options:
|
100
|
-
input: |
|
101
|
-
<table>
|
102
|
-
<tbody>
|
103
|
-
<%
|
104
|
-
$i = 0;
|
105
|
-
foreach ($list as $item) {
|
106
|
-
$i++;
|
107
|
-
%>
|
108
|
-
<tr>
|
109
|
-
<td><%= $i %></td>
|
110
|
-
<td><%== $item %></td>
|
111
|
-
</tr>
|
112
|
-
<%
|
113
|
-
}
|
114
|
-
%>
|
115
|
-
</tbody>
|
116
|
-
</table>
|
117
|
-
<%=== $i %>
|
118
|
-
expected: |
|
119
|
-
<table>
|
120
|
-
<tbody>
|
121
|
-
<?php
|
122
|
-
$i = 0;
|
123
|
-
foreach ($list as $item) {
|
124
|
-
$i++;
|
125
|
-
?>
|
126
|
-
<tr>
|
127
|
-
<td><?php echo $i; ?></td>
|
128
|
-
<td><?php echo htmlspecialchars($item); ?></td>
|
129
|
-
</tr>
|
130
|
-
<?php
|
131
|
-
}
|
132
|
-
?>
|
133
|
-
</tbody>
|
134
|
-
</table>
|
135
|
-
<?php error_log('*** debug: $i='.($i), 0); ?>
|
136
|
-
##
|
137
|
-
- name: c1
|
138
|
-
lang: c
|
139
|
-
class: Ec
|
140
|
-
options: { :filename: foo.html, :indent: ' ' }
|
141
|
-
input: |4
|
142
|
-
<table>
|
143
|
-
<tbody>
|
144
|
-
<% for (i = 0; i < list; i++) { %>
|
145
|
-
<tr>
|
146
|
-
<td><%= "%d", i %></td>
|
147
|
-
<td><%== list[i] %></td>
|
148
|
-
</tr>
|
149
|
-
<% } %>
|
150
|
-
</tbody>
|
151
|
-
</table>
|
152
|
-
<%=== "%d", i %>
|
153
|
-
expected: |
|
154
|
-
#line 1 "foo.html"
|
155
|
-
fputs("<table>\n"
|
156
|
-
" <tbody>\n", stdout);
|
157
|
-
for (i = 0; i < list; i++) {
|
158
|
-
fputs(" <tr>\n"
|
159
|
-
" <td>", stdout); fprintf(stdout, "%d", i); fputs("</td>\n"
|
160
|
-
" <td>", stdout); escape(list[i], stdout); fputs("</td>\n"
|
161
|
-
" </tr>\n", stdout);
|
162
|
-
}
|
163
|
-
fputs(" </tbody>\n"
|
164
|
-
"</table>\n", stdout);
|
165
|
-
fprintf(stderr, "*** debug: i=" "%d", i); fputs("\n", stdout);
|
166
|
-
##
|
167
|
-
- name: cpp1
|
168
|
-
lang: cpp
|
169
|
-
class: Ecpp
|
170
|
-
options: { :filename: foo.html, :indent: ' ' }
|
171
|
-
input: |4
|
172
|
-
<table>
|
173
|
-
<tbody>
|
174
|
-
<% for (i = 0; i < n; i++) { %>
|
175
|
-
<tr>
|
176
|
-
<td><%= i %></td>
|
177
|
-
<td><%== list[i] %></td>
|
178
|
-
</tr>
|
179
|
-
<% } %>
|
180
|
-
</tbody>
|
181
|
-
</table>
|
182
|
-
<%=== i %>
|
183
|
-
expected: |
|
184
|
-
#line 1 "foo.html"
|
185
|
-
_buf << "<table>\n"
|
186
|
-
" <tbody>\n";
|
187
|
-
for (i = 0; i < n; i++) {
|
188
|
-
_buf << " <tr>\n"
|
189
|
-
" <td>"; _buf << (i); _buf << "</td>\n"
|
190
|
-
" <td>"; escape(list[i]); _buf << "</td>\n"
|
191
|
-
" </tr>\n";
|
192
|
-
}
|
193
|
-
_buf << " </tbody>\n"
|
194
|
-
"</table>\n";
|
195
|
-
std::cerr << "*** debug: i=" << (i); _buf << "\n";
|
196
|
-
##
|
197
|
-
- name: java1
|
198
|
-
lang: java
|
199
|
-
class: Ejava
|
200
|
-
options: { :buf: _buf, :bufclass: StringBuilder, :indent: ' ' }
|
201
|
-
input: |
|
202
|
-
<table>
|
203
|
-
<tbody>
|
204
|
-
<%
|
205
|
-
int i = 0;
|
206
|
-
for (Iterator it = list.iterator(); it.hasNext(); ) {
|
207
|
-
String s = (String)it.next();
|
208
|
-
i++;
|
209
|
-
%>
|
210
|
-
<tr class="<%= i%2==0 ? "even" : "odd" %>">
|
211
|
-
<td><%= i %></td>
|
212
|
-
<td><%== s %></td>
|
213
|
-
</tr>
|
214
|
-
<%
|
215
|
-
}
|
216
|
-
%>
|
217
|
-
<tbody>
|
218
|
-
</table>
|
219
|
-
<%=== i %>
|
220
|
-
expected: |4
|
221
|
-
StringBuilder _buf = new StringBuilder(); _buf.append("<table>\n"
|
222
|
-
+ " <tbody>\n");
|
223
|
-
|
224
|
-
int i = 0;
|
225
|
-
for (Iterator it = list.iterator(); it.hasNext(); ) {
|
226
|
-
String s = (String)it.next();
|
227
|
-
i++;
|
228
|
-
|
229
|
-
_buf.append(" <tr class=\""); _buf.append(i%2==0 ? "even" : "odd"); _buf.append("\">\n"
|
230
|
-
+ " <td>"); _buf.append(i); _buf.append("</td>\n"
|
231
|
-
+ " <td>"); _buf.append(escape(s)); _buf.append("</td>\n"
|
232
|
-
+ " </tr>\n");
|
233
|
-
|
234
|
-
}
|
235
|
-
|
236
|
-
_buf.append(" <tbody>\n"
|
237
|
-
+ "</table>\n");
|
238
|
-
System.err.println("*** debug: i="+(i)); _buf.append("\n");
|
239
|
-
return _buf.toString();
|
240
|
-
##
|
241
|
-
- name: scheme1
|
242
|
-
lang: scheme
|
243
|
-
class: Escheme
|
244
|
-
options:
|
245
|
-
input: &scheme1_input|
|
246
|
-
<% (let ((i 0)) %>
|
247
|
-
<table>
|
248
|
-
<tbody>
|
249
|
-
<%
|
250
|
-
(for-each
|
251
|
-
(lambda (item)
|
252
|
-
(set! i (+ i 1))
|
253
|
-
%>
|
254
|
-
<tr>
|
255
|
-
<td><%= i %></td>
|
256
|
-
<td><%== item %></td>
|
257
|
-
</tr>
|
258
|
-
<%
|
259
|
-
); lambda end
|
260
|
-
list); for-each end
|
261
|
-
%>
|
262
|
-
</tbody>
|
263
|
-
</table>
|
264
|
-
<%=== i %>
|
265
|
-
<% ); let end %>
|
266
|
-
expected: |4
|
267
|
-
(let ((_buf '())) (define (_add x) (set! _buf (cons x _buf))) (let ((i 0))
|
268
|
-
(_add "<table>
|
269
|
-
<tbody>\n")
|
270
|
-
|
271
|
-
(for-each
|
272
|
-
(lambda (item)
|
273
|
-
(set! i (+ i 1))
|
274
|
-
|
275
|
-
(_add " <tr>
|
276
|
-
<td>")(_add i)(_add "</td>
|
277
|
-
<td>")(_add (escape item))(_add "</td>
|
278
|
-
</tr>\n")
|
279
|
-
|
280
|
-
); lambda end
|
281
|
-
list); for-each end
|
282
|
-
|
283
|
-
(_add " </tbody>
|
284
|
-
</table>\n")
|
285
|
-
(display "*** debug: i=")(display i)(display "\n")(_add "\n")
|
286
|
-
); let end
|
287
|
-
(reverse _buf))
|
288
|
-
|
289
|
-
##
|
290
|
-
- name: scheme2
|
291
|
-
lang: scheme
|
292
|
-
class: Escheme
|
293
|
-
options: { :func: 'display' }
|
294
|
-
input: *scheme1_input
|
295
|
-
expected: |4
|
296
|
-
(let ((i 0))
|
297
|
-
(display "<table>
|
298
|
-
<tbody>\n")
|
299
|
-
|
300
|
-
(for-each
|
301
|
-
(lambda (item)
|
302
|
-
(set! i (+ i 1))
|
303
|
-
|
304
|
-
(display " <tr>
|
305
|
-
<td>")(display i)(display "</td>
|
306
|
-
<td>")(display (escape item))(display "</td>
|
307
|
-
</tr>\n")
|
308
|
-
|
309
|
-
); lambda end
|
310
|
-
list); for-each end
|
311
|
-
|
312
|
-
(display " </tbody>
|
313
|
-
</table>\n")
|
314
|
-
(display "*** debug: i=")(display i)(display "\n")(display "\n")
|
315
|
-
); let end
|
316
|
-
##
|
317
|
-
- name: perl1
|
318
|
-
lang: perl
|
319
|
-
class: Eperl
|
320
|
-
options:
|
321
|
-
input: |
|
322
|
-
<%
|
323
|
-
my $user = 'Erubis';
|
324
|
-
my @list = ('<aaa>', 'b&b', '"ccc"');
|
325
|
-
%>
|
326
|
-
<p>Hello <%= $user %>!</p>
|
327
|
-
<table>
|
328
|
-
<tbody>
|
329
|
-
<% $i = 0; %>
|
330
|
-
<% for $item (@list) { %>
|
331
|
-
<tr bgcolor=<%= ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
|
332
|
-
<td><%= $i %></td>
|
333
|
-
<td><%== $item %></td>
|
334
|
-
</tr>
|
335
|
-
<% } %>
|
336
|
-
</tbody>
|
337
|
-
</table>
|
338
|
-
<%=== $i %>
|
339
|
-
expected: |4
|
340
|
-
use HTML::Entities;
|
341
|
-
my $user = 'Erubis';
|
342
|
-
my @list = ('<aaa>', 'b&b', '"ccc"');
|
343
|
-
|
344
|
-
print('<p>Hello '); print($user); print('!</p>
|
345
|
-
<table>
|
346
|
-
<tbody>
|
347
|
-
'); $i = 0;
|
348
|
-
for $item (@list) {
|
349
|
-
print(' <tr bgcolor='); print(++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); print('">
|
350
|
-
<td>'); print($i); print('</td>
|
351
|
-
<td>'); print(encode_entities($item)); print('</td>
|
352
|
-
</tr>
|
353
|
-
'); }
|
354
|
-
print(' </tbody>
|
355
|
-
</table>
|
356
|
-
'); print('*** debug: $i=', $i, "\n");print('
|
357
|
-
');
|
358
|
-
##
|
359
|
-
- name: javascript1
|
360
|
-
lang: javascript
|
361
|
-
class: Ejavascript
|
362
|
-
options:
|
363
|
-
input: &javascript_input |
|
364
|
-
<%
|
365
|
-
var user = 'Erubis';
|
366
|
-
var list = ['<aaa>', 'b&b', '"ccc"'];
|
367
|
-
%>
|
368
|
-
<p>Hello <%= user %>!</p>
|
369
|
-
<table>
|
370
|
-
<tbody>
|
371
|
-
<% var i; %>
|
372
|
-
<% for (i = 0; i < list.length; i++) { %>
|
373
|
-
<tr bgcolor=<%= ++i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
|
374
|
-
<td><%= i %></td>
|
375
|
-
<td><%= list[i] %></td>
|
376
|
-
</tr>
|
377
|
-
<% } %>
|
378
|
-
</tbody>
|
379
|
-
</table>
|
380
|
-
<%=== i %>
|
381
|
-
expected: |4
|
382
|
-
var _buf = [];
|
383
|
-
var user = 'Erubis';
|
384
|
-
var list = ['<aaa>', 'b&b', '"ccc"'];
|
385
|
-
|
386
|
-
_buf.push("<p>Hello "); _buf.push(user); _buf.push("!</p>\n\
|
387
|
-
<table>\n\
|
388
|
-
<tbody>\n");
|
389
|
-
var i;
|
390
|
-
for (i = 0; i < list.length; i++) {
|
391
|
-
_buf.push(" <tr bgcolor="); _buf.push(++i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); _buf.push("\">\n\
|
392
|
-
<td>"); _buf.push(i); _buf.push("</td>\n\
|
393
|
-
<td>"); _buf.push(list[i]); _buf.push("</td>\n\
|
394
|
-
</tr>\n");
|
395
|
-
}
|
396
|
-
_buf.push(" </tbody>\n\
|
397
|
-
</table>\n");
|
398
|
-
alert("*** debug: i="+(i)); _buf.push("\n");
|
399
|
-
document.write(_buf.join(""));
|
400
|
-
##
|
401
|
-
- name: javascript2
|
402
|
-
lang: javascript
|
403
|
-
class: Ejavascript
|
404
|
-
options: { :docwrite: false }
|
405
|
-
input: *javascript_input
|
406
|
-
expected: |4
|
407
|
-
var _buf = [];
|
408
|
-
var user = 'Erubis';
|
409
|
-
var list = ['<aaa>', 'b&b', '"ccc"'];
|
410
|
-
|
411
|
-
_buf.push("<p>Hello "); _buf.push(user); _buf.push("!</p>\n\
|
412
|
-
<table>\n\
|
413
|
-
<tbody>\n");
|
414
|
-
var i;
|
415
|
-
for (i = 0; i < list.length; i++) {
|
416
|
-
_buf.push(" <tr bgcolor="); _buf.push(++i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); _buf.push("\">\n\
|
417
|
-
<td>"); _buf.push(i); _buf.push("</td>\n\
|
418
|
-
<td>"); _buf.push(list[i]); _buf.push("</td>\n\
|
419
|
-
</tr>\n");
|
420
|
-
}
|
421
|
-
_buf.push(" </tbody>\n\
|
422
|
-
</table>\n");
|
423
|
-
alert("*** debug: i="+(i)); _buf.push("\n");
|
424
|
-
_buf.join("");
|
425
|
-
##
|