erbse 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.txt +828 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +51 -0
  5. data/benchmark/Makefile +6 -0
  6. data/benchmark/bench.rb +313 -0
  7. data/benchmark/bench_context.yaml +141 -0
  8. data/benchmark/templates/_footer.html +4 -0
  9. data/benchmark/templates/_header.html +52 -0
  10. data/benchmark/templates/bench_erb.rhtml +29 -0
  11. data/benchmark/templates/bench_erubis.rhtml +29 -0
  12. data/benchmark/templates/bench_eruby.rhtml +29 -0
  13. data/bin/erubis +10 -0
  14. data/erbse.gemspec +24 -0
  15. data/lib/erbse.rb +52 -0
  16. data/lib/erbse/context.rb +83 -0
  17. data/lib/erbse/converter.rb +357 -0
  18. data/lib/erbse/engine.rb +114 -0
  19. data/lib/erbse/engine/ec.rb +117 -0
  20. data/lib/erbse/engine/ecpp.rb +113 -0
  21. data/lib/erbse/engine/ejava.rb +110 -0
  22. data/lib/erbse/engine/ejavascript.rb +119 -0
  23. data/lib/erbse/engine/enhanced.rb +126 -0
  24. data/lib/erbse/engine/eperl.rb +95 -0
  25. data/lib/erbse/engine/ephp.rb +99 -0
  26. data/lib/erbse/engine/eruby.rb +119 -0
  27. data/lib/erbse/engine/escheme.rb +114 -0
  28. data/lib/erbse/engine/optimized.rb +127 -0
  29. data/lib/erbse/enhancer.rb +723 -0
  30. data/lib/erbse/error.rb +23 -0
  31. data/lib/erbse/evaluator.rb +88 -0
  32. data/lib/erbse/generator.rb +85 -0
  33. data/lib/erbse/helper.rb +47 -0
  34. data/lib/erbse/helpers/rails_form_helper.rb +197 -0
  35. data/lib/erbse/helpers/rails_helper.rb +353 -0
  36. data/lib/erbse/main.rb +516 -0
  37. data/lib/erbse/preprocessing.rb +58 -0
  38. data/lib/erbse/tiny.rb +144 -0
  39. data/lib/erbse/util.rb +22 -0
  40. data/lib/erbse/version.rb +3 -0
  41. data/test/assert-text-equal.rb +44 -0
  42. data/test/data/users-guide/Example.ejava +55 -0
  43. data/test/data/users-guide/array_example.result +9 -0
  44. data/test/data/users-guide/arraybuffer_example.result +9 -0
  45. data/test/data/users-guide/bipattern-example.rhtml +4 -0
  46. data/test/data/users-guide/bipattern_example.result +6 -0
  47. data/test/data/users-guide/bufvar-example.rb +10 -0
  48. data/test/data/users-guide/bufvar-example.result +17 -0
  49. data/test/data/users-guide/context.rb +6 -0
  50. data/test/data/users-guide/context.yaml +8 -0
  51. data/test/data/users-guide/def_method.rb +14 -0
  52. data/test/data/users-guide/def_method.result +3 -0
  53. data/test/data/users-guide/escape_example.result +9 -0
  54. data/test/data/users-guide/example.ec +27 -0
  55. data/test/data/users-guide/example.ecpp +30 -0
  56. data/test/data/users-guide/example.ejs +20 -0
  57. data/test/data/users-guide/example.eperl +18 -0
  58. data/test/data/users-guide/example.ephp +18 -0
  59. data/test/data/users-guide/example.eruby +6 -0
  60. data/test/data/users-guide/example.escheme +28 -0
  61. data/test/data/users-guide/example1.eruby +6 -0
  62. data/test/data/users-guide/example1.rb +17 -0
  63. data/test/data/users-guide/example1.result +16 -0
  64. data/test/data/users-guide/example10.rb +4 -0
  65. data/test/data/users-guide/example10.result +17 -0
  66. data/test/data/users-guide/example10.xhtml +14 -0
  67. data/test/data/users-guide/example10_x.result +17 -0
  68. data/test/data/users-guide/example11.php +20 -0
  69. data/test/data/users-guide/example11.result +23 -0
  70. data/test/data/users-guide/example11.rhtml +21 -0
  71. data/test/data/users-guide/example11_C.result +10 -0
  72. data/test/data/users-guide/example11_N.result +16 -0
  73. data/test/data/users-guide/example11_U.result +16 -0
  74. data/test/data/users-guide/example11_php.result +15 -0
  75. data/test/data/users-guide/example1_x.result +9 -0
  76. data/test/data/users-guide/example2.eruby +7 -0
  77. data/test/data/users-guide/example2.rb +10 -0
  78. data/test/data/users-guide/example2.result +27 -0
  79. data/test/data/users-guide/example2_trim.result +10 -0
  80. data/test/data/users-guide/example2_x.result +10 -0
  81. data/test/data/users-guide/example3.eruby +6 -0
  82. data/test/data/users-guide/example3.rb +10 -0
  83. data/test/data/users-guide/example31.result +22 -0
  84. data/test/data/users-guide/example32.result +4 -0
  85. data/test/data/users-guide/example3_e.result +8 -0
  86. data/test/data/users-guide/example4.eruby +3 -0
  87. data/test/data/users-guide/example4.rb +11 -0
  88. data/test/data/users-guide/example4.result +10 -0
  89. data/test/data/users-guide/example4_x.result +5 -0
  90. data/test/data/users-guide/example5.eruby +6 -0
  91. data/test/data/users-guide/example5.rb +16 -0
  92. data/test/data/users-guide/example5.result +7 -0
  93. data/test/data/users-guide/example6.rb +12 -0
  94. data/test/data/users-guide/example6.result +7 -0
  95. data/test/data/users-guide/example7.eruby +8 -0
  96. data/test/data/users-guide/example71.result +13 -0
  97. data/test/data/users-guide/example72.result +13 -0
  98. data/test/data/users-guide/example8.eruby +6 -0
  99. data/test/data/users-guide/example8_ruby.result +7 -0
  100. data/test/data/users-guide/example8_yaml.result +7 -0
  101. data/test/data/users-guide/example9.eruby +3 -0
  102. data/test/data/users-guide/example9.rb +8 -0
  103. data/test/data/users-guide/example9.result +9 -0
  104. data/test/data/users-guide/example91.result +5 -0
  105. data/test/data/users-guide/example92.result +4 -0
  106. data/test/data/users-guide/example_c.result +32 -0
  107. data/test/data/users-guide/example_java.result +56 -0
  108. data/test/data/users-guide/example_js.result +22 -0
  109. data/test/data/users-guide/example_perl.result +20 -0
  110. data/test/data/users-guide/example_php.result +19 -0
  111. data/test/data/users-guide/example_scheme.result +30 -0
  112. data/test/data/users-guide/example_scheme_display.result +29 -0
  113. data/test/data/users-guide/fasteruby-example.rb +8 -0
  114. data/test/data/users-guide/fasteruby-example.result +18 -0
  115. data/test/data/users-guide/fasteruby.rb +11 -0
  116. data/test/data/users-guide/fasteruby.result +38 -0
  117. data/test/data/users-guide/fasteruby.rhtml +15 -0
  118. data/test/data/users-guide/headerfooter-example.eruby +9 -0
  119. data/test/data/users-guide/headerfooter-example2.rb +8 -0
  120. data/test/data/users-guide/headerfooter-example2.rhtml +10 -0
  121. data/test/data/users-guide/headerfooter_example.result +11 -0
  122. data/test/data/users-guide/headerfooter_example2.result +13 -0
  123. data/test/data/users-guide/interpolation_example.result +9 -0
  124. data/test/data/users-guide/main_program1.rb +8 -0
  125. data/test/data/users-guide/main_program1.result +6 -0
  126. data/test/data/users-guide/main_program2.rb +8 -0
  127. data/test/data/users-guide/main_program2.result +6 -0
  128. data/test/data/users-guide/nocode-example.eruby +14 -0
  129. data/test/data/users-guide/nocode-php.result +20 -0
  130. data/test/data/users-guide/nocode_example.result +15 -0
  131. data/test/data/users-guide/normal-eruby-test.eruby +9 -0
  132. data/test/data/users-guide/normal_eruby_test.result +11 -0
  133. data/test/data/users-guide/notext-example.eruby +14 -0
  134. data/test/data/users-guide/notext-example.php +19 -0
  135. data/test/data/users-guide/notext-php.result +20 -0
  136. data/test/data/users-guide/notext_example.result +16 -0
  137. data/test/data/users-guide/percentline-example.rhtml +6 -0
  138. data/test/data/users-guide/percentline_example.result +9 -0
  139. data/test/data/users-guide/prefixedline-example.rb +9 -0
  140. data/test/data/users-guide/prefixedline-example.rhtml +6 -0
  141. data/test/data/users-guide/prefixedline_example.result +9 -0
  142. data/test/data/users-guide/printenable_example.result +4 -0
  143. data/test/data/users-guide/printenabled-example.eruby +3 -0
  144. data/test/data/users-guide/printenabled-example.rb +8 -0
  145. data/test/data/users-guide/printstatement_example.result +8 -0
  146. data/test/data/users-guide/simplify_example.result +9 -0
  147. data/test/data/users-guide/stderr.log +3 -0
  148. data/test/data/users-guide/stdout_exmple.result +9 -0
  149. data/test/data/users-guide/stringbuffer_example.result +9 -0
  150. data/test/data/users-guide/tail_260.result +4 -0
  151. data/test/data/users-guide/tailnewline.rhtml +3 -0
  152. data/test/data/users-guide/template1.rhtml +4 -0
  153. data/test/data/users-guide/template2.rhtml +4 -0
  154. data/test/test-engines.rb +425 -0
  155. data/test/test-enhancers.rb +646 -0
  156. data/test/test-erubis.rb +887 -0
  157. data/test/test-index-cgi.rb +191 -0
  158. data/test/test-main.rb +752 -0
  159. data/test/test-users-guide.rb +73 -0
  160. data/test/test.rb +45 -0
  161. data/test/testutil.rb +111 -0
  162. metadata +233 -0
@@ -0,0 +1,646 @@
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 'stringio'
9
+
10
+ require 'erubis'
11
+ require 'erubis/engine/enhanced'
12
+ require 'erubis/engine/optimized'
13
+
14
+
15
+ class EnhancersTest < Test::Unit::TestCase
16
+
17
+ testdata_list = load_yaml_datafile(__FILE__)
18
+ define_testmethods(testdata_list)
19
+
20
+
21
+ def _test()
22
+ @src.gsub!(/\^/, ' ')
23
+ @output.gsub!(/\^/, ' ') if @output.is_a?(String)
24
+ if @class
25
+ k = Erubis
26
+ @class.split('::').each do |name| k = k.const_get(name) end
27
+ @klass = k
28
+ else
29
+ @klass = Erubis::Eruby
30
+ end
31
+ @options ||= {}
32
+ @chomp.each do |target|
33
+ case target
34
+ when 'src' ; @src.chomp!
35
+ when 'input' ; @input.chomp!
36
+ when 'expected' ; @expected.chomp!
37
+ else
38
+ raise "#{@name}: invalid chomp value: #{@chomp.inspect}"
39
+ end
40
+ end if @chomp
41
+
42
+ if @testopt == 'load_file'
43
+ filename = "tmp.#{@name}.eruby"
44
+ begin
45
+ File.open(filename, 'w') { |f| f.write(@input) }
46
+ eruby = @klass.load_file(filename, @options)
47
+ ensure
48
+ cachename = filename + '.cache'
49
+ File.unlink(cachename) if test(?f, cachename)
50
+ File.unlink(filename) if test(?f, filename)
51
+ end
52
+ else
53
+ #if @klass == Erubis::TinyEruby
54
+ # eruby = @klass.new(@input)
55
+ #else
56
+ eruby = @klass.new(@input, @options)
57
+ #end
58
+ end
59
+ assert_text_equal(@src, eruby.src)
60
+
61
+ return if @testopt == 'skip_output'
62
+
63
+ list = ['<aaa>', 'b&b', '"ccc"']
64
+ context = @testopt == 'context' ? Erubis::Context.new : {}
65
+ context[:list] = list
66
+
67
+ case @testopt
68
+ when /\Aeval\(/
69
+ eval eruby.src
70
+ actual = eval @testopt
71
+ assert_text_equal(@output, actual)
72
+ when 'stdout', 'print'
73
+ begin
74
+ orig = $stdout
75
+ $stdout = stringio = StringIO.new
76
+ #actual = eruby.evaluate(context)
77
+ actual = eruby.result(context)
78
+ ensure
79
+ $stdout = orig
80
+ end
81
+ if @testopt == 'stdout'
82
+ assert_equal("", actual)
83
+ else
84
+ assert_nil(actual)
85
+ end
86
+ assert_text_equal(@output, stringio.string)
87
+ when 'evaluate', 'context'
88
+ actual = eruby.evaluate(context)
89
+ assert_text_equal(@output, actual)
90
+ when 'binding'
91
+ actual = eruby.result(binding())
92
+ assert_text_equal(@output, actual)
93
+ else
94
+ actual = eruby.result(context)
95
+ assert_text_equal(@output, actual)
96
+ end
97
+ end
98
+
99
+
100
+ self.post_definition()
101
+
102
+ end
103
+
104
+ __END__
105
+
106
+ ##
107
+ - name: basic1
108
+ class: Eruby
109
+ input: &basic1_input|
110
+ <ul>
111
+ <% for item in list %>
112
+ <li><%= item %></li>
113
+ <% end %>
114
+ </ul>
115
+ src: &basic1_src|
116
+ _buf = ''; _buf << '<ul>
117
+ '; for item in list
118
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
119
+ '; end
120
+ _buf << '</ul>
121
+ ';
122
+ _buf.to_s
123
+ output: &basic1_output|
124
+ <ul>
125
+ <li><aaa></li>
126
+ <li>b&b</li>
127
+ <li>"ccc"</li>
128
+ </ul>
129
+
130
+ - name: xml1
131
+ class: XmlEruby
132
+ input: |
133
+ <pre>
134
+ <% for item in list %>
135
+ <%= item %>
136
+ <%== item %>
137
+ <% end %>
138
+ </pre>
139
+ src: |
140
+ _buf = ''; _buf << '<pre>
141
+ '; for item in list
142
+ _buf << ' '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '
143
+ '; _buf << ' '; _buf << ( item ).to_s; _buf << '
144
+ '; end
145
+ _buf << '</pre>
146
+ ';
147
+ _buf.to_s
148
+ output: |
149
+ <pre>
150
+ &lt;aaa&gt;
151
+ <aaa>
152
+ b&amp;b
153
+ b&b
154
+ &quot;ccc&quot;
155
+ "ccc"
156
+ </pre>
157
+
158
+ ##
159
+ - name: xml2
160
+ class: XmlEruby
161
+ testopt: skip_output
162
+ input: |
163
+ <% for item in list %>
164
+ <%= item["var#{n}"] %>
165
+ <%== item["var#{n}"] %>
166
+ <%=== item["var#{n}"] %>
167
+ <%==== item["var#{n}"] %>
168
+ <% end %>
169
+ src: |
170
+ _buf = ''; for item in list
171
+ _buf << ' '; _buf << Erubis::XmlHelper.escape_xml( item["var#{n}"] ); _buf << '
172
+ '; _buf << ' '; _buf << ( item["var#{n}"] ).to_s; _buf << '
173
+ '; _buf << ' '; $stderr.puts("*** debug: item[\"var\#{n}\"]=#{(item["var#{n}"]).inspect}"); _buf << '
174
+ '; _buf << ' '; _buf << '
175
+ '; end
176
+ _buf.to_s
177
+ output: |
178
+
179
+ ##
180
+ - name: printout1
181
+ class: PrintOutEruby
182
+ testopt: print
183
+ input: *basic1_input
184
+ src: |4
185
+ print '<ul>
186
+ '; for item in list
187
+ print ' <li>'; print(( item ).to_s); print '</li>
188
+ '; end
189
+ print '</ul>
190
+ ';
191
+ output: *basic1_output
192
+
193
+ ##
194
+ - name: printenabled1
195
+ class: PrintEnabledEruby
196
+ input: &printenabled1_input|
197
+ <ul>
198
+ <% for item in list %>
199
+ <li><% print item %></li>
200
+ <% end %>
201
+ </ul>
202
+ src: |
203
+ @_buf = _buf = ''; _buf << '<ul>
204
+ '; for item in list
205
+ _buf << ' <li>'; print item ; _buf << '</li>
206
+ '; end
207
+ _buf << '</ul>
208
+ ';
209
+ _buf.to_s
210
+ output: *basic1_output
211
+ # <ul>
212
+ # <li><aaa></li>
213
+ # <li>b&b</li>
214
+ # <li>"ccc"</li>
215
+ # </ul>
216
+
217
+ ##
218
+ - name: stdout1
219
+ class: StdoutEruby
220
+ testopt: stdout
221
+ input: *basic1_input
222
+ # <ul>
223
+ # <% for item in list %>
224
+ # <li><%= item %></li>
225
+ # <% end %>
226
+ # </ul>
227
+ src: |
228
+ _buf = $stdout; _buf << '<ul>
229
+ '; for item in list
230
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
231
+ '; end
232
+ _buf << '</ul>
233
+ ';
234
+ ''
235
+ output: *basic1_output
236
+ # <ul>
237
+ # <li><aaa></li>
238
+ # <li>b&b</li>
239
+ # <li>"ccc"</li>
240
+ # </ul>
241
+
242
+ ##
243
+ - name: array1
244
+ class: ArrayEruby
245
+ input: |
246
+ <ul>
247
+ <% for item in list %>
248
+ <li><%= item %></li>
249
+ <% end %>
250
+ </ul>
251
+ src: |
252
+ _buf = []; _buf << '<ul>
253
+ '; for item in list
254
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
255
+ '; end
256
+ _buf << '</ul>
257
+ ';
258
+ _buf
259
+ output:
260
+ - "<ul>\n"
261
+ - " <li>"
262
+ - "<aaa>"
263
+ - "</li>\n"
264
+ - " <li>"
265
+ - "b&b"
266
+ - "</li>\n"
267
+ - " <li>"
268
+ - "\"ccc\""
269
+ - "</li>\n"
270
+ - "</ul>\n"
271
+
272
+ ##
273
+ - name: arraybuffer1
274
+ class: ArrayBufferEruby
275
+ input: *basic1_input
276
+ src: |
277
+ _buf = []; _buf << '<ul>
278
+ '; for item in list
279
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
280
+ '; end
281
+ _buf << '</ul>
282
+ ';
283
+ _buf.join
284
+ output: *basic1_output
285
+
286
+ - name: stringbuffer1
287
+ class: StringBufferEruby
288
+ input: *basic1_input
289
+ # <ul>
290
+ # <% for item in list %>
291
+ # <li><%= item %></li>
292
+ # <% end %>
293
+ # </ul>
294
+ src: |
295
+ _buf = ''; _buf << '<ul>
296
+ '; for item in list
297
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
298
+ '; end
299
+ _buf << '</ul>
300
+ ';
301
+ _buf.to_s
302
+ output: *basic1_output
303
+ # <ul>
304
+ # <li><aaa></li>
305
+ # <li>b&b</li>
306
+ # <li>"ccc"</li>
307
+ # </ul>
308
+
309
+ ##
310
+ - name: erbout1
311
+ class: ErboutEruby
312
+ input: *basic1_input
313
+ src: |
314
+ _erbout = _buf = ''; _buf << '<ul>
315
+ '; for item in list
316
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
317
+ '; end
318
+ _buf << '</ul>
319
+ ';
320
+ _buf.to_s
321
+ output: *basic1_output
322
+
323
+ ##
324
+ - name: stringio1
325
+ class: StringIOEruby
326
+ input: *basic1_input
327
+ src: |
328
+ _buf = StringIO.new; _buf << '<ul>
329
+ '; for item in list
330
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
331
+ '; end
332
+ _buf << '</ul>
333
+ ';
334
+ _buf.string
335
+ output: *basic1_output
336
+
337
+ ##
338
+ - name: notext1
339
+ class: NoTextEruby
340
+ input: *basic1_input
341
+ src: |
342
+ _buf = '';
343
+ for item in list
344
+ _buf << ( item ).to_s;
345
+ end
346
+
347
+ _buf.to_s
348
+ output: '<aaa>b&b"ccc"'
349
+
350
+
351
+ ##
352
+ - name: nocode1
353
+ class: NoCodeEruby
354
+ testopt: skip_output
355
+ input: *basic1_input
356
+ src: |
357
+ <ul>
358
+
359
+ <li></li>
360
+
361
+ </ul>
362
+ output:
363
+
364
+ ##
365
+ - name: simplified
366
+ class: SimplifiedEruby
367
+ input: |
368
+ <ul>
369
+ <% for item in list %>
370
+ <li>
371
+ <%= item %>
372
+ </li>
373
+ <% end %>
374
+ </ul>
375
+ src: |
376
+ _buf = ''; _buf << '<ul>
377
+ '; for item in list ; _buf << '
378
+ <li>
379
+ '; _buf << ( item ).to_s; _buf << '
380
+ </li>
381
+ '; end ; _buf << '
382
+ </ul>
383
+ ';
384
+ _buf.to_s
385
+ output: |
386
+ <ul>
387
+ ^
388
+ <li>
389
+ <aaa>
390
+ </li>
391
+ ^
392
+ <li>
393
+ b&b
394
+ </li>
395
+ ^
396
+ <li>
397
+ "ccc"
398
+ </li>
399
+ ^
400
+ </ul>
401
+
402
+ ##
403
+ - name: bipattern1
404
+ class: BiPatternEruby
405
+ #options: { :bipattern : '\[= =\]' }
406
+ input: |
407
+ <% for item in list %>
408
+ <%= item %> % <%== item %>
409
+ [= item =] = [== item =]
410
+ <% end %>
411
+ src: |
412
+ _buf = ''; for item in list
413
+ _buf << ' '; _buf << ( item ).to_s; _buf << ' % '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '
414
+ '; _buf << ' '; _buf << ( item ).to_s; _buf << ' = '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '
415
+ '; end
416
+ _buf.to_s
417
+ output: |4
418
+ <aaa> % &lt;aaa&gt;
419
+ <aaa> = &lt;aaa&gt;
420
+ b&b % b&amp;b
421
+ b&b = b&amp;b
422
+ "ccc" % &quot;ccc&quot;
423
+ "ccc" = &quot;ccc&quot;
424
+
425
+ ##
426
+ - name: bipattern2
427
+ class: BiPatternEruby
428
+ options: { :bipattern: '\$\{ \}' }
429
+ input: |
430
+ <% for item in list %>
431
+ <%=item%> % <%==item%>
432
+ ${item} = ${=item}
433
+ <% end %>
434
+ src: |
435
+ _buf = ''; for item in list
436
+ _buf << ' '; _buf << (item).to_s; _buf << ' % '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '
437
+ '; _buf << ' '; _buf << (item).to_s; _buf << ' = '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '
438
+ '; end
439
+ _buf.to_s
440
+ output: |4
441
+ <aaa> % &lt;aaa&gt;
442
+ <aaa> = &lt;aaa&gt;
443
+ b&b % b&amp;b
444
+ b&b = b&amp;b
445
+ "ccc" % &quot;ccc&quot;
446
+ "ccc" = &quot;ccc&quot;
447
+
448
+ ##
449
+ - name: percentline1
450
+ class: PercentLineEruby
451
+ options:
452
+ input: |
453
+ <table>
454
+ % for item in list
455
+ <tr>
456
+ <td><%= item %></td>
457
+ <td><%== item %></td>
458
+ </tr>
459
+ % end
460
+ </table>
461
+ <pre>
462
+ %% double percent
463
+ % spaced percent
464
+ </pre>
465
+ src: |
466
+ _buf = ''; _buf << '<table>
467
+ '; for item in list
468
+ _buf << ' <tr>
469
+ <td>'; _buf << ( item ).to_s; _buf << '</td>
470
+ <td>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</td>
471
+ </tr>
472
+ '; end
473
+ _buf << '</table>
474
+ <pre>
475
+ % double percent
476
+ % spaced percent
477
+ </pre>
478
+ ';
479
+ _buf.to_s
480
+ output: |
481
+ <table>
482
+ <tr>
483
+ <td><aaa></td>
484
+ <td>&lt;aaa&gt;</td>
485
+ </tr>
486
+ <tr>
487
+ <td>b&b</td>
488
+ <td>b&amp;b</td>
489
+ </tr>
490
+ <tr>
491
+ <td>"ccc"</td>
492
+ <td>&quot;ccc&quot;</td>
493
+ </tr>
494
+ </table>
495
+ <pre>
496
+ % double percent
497
+ % spaced percent
498
+ </pre>
499
+
500
+ ##
501
+ - name: prefixedline1
502
+ class: PrefixedLineEruby
503
+ options: { :prefixchar: '!' }
504
+ input: |
505
+ <table>
506
+ ! for item in list
507
+ <tr>
508
+ <td><%= item %></td>
509
+ <td><%== item %></td>
510
+ </tr>
511
+ ! end
512
+ </table>
513
+ <pre>
514
+ !! doubled characters
515
+ </pre>
516
+ src: |
517
+ _buf = ''; _buf << '<table>
518
+ '; for item in list
519
+ _buf << ' <tr>
520
+ <td>'; _buf << ( item ).to_s; _buf << '</td>
521
+ <td>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</td>
522
+ </tr>
523
+ '; end
524
+ _buf << '</table>
525
+ <pre>
526
+ ! doubled characters
527
+ </pre>
528
+ ';
529
+ _buf.to_s
530
+ output: |
531
+ <table>
532
+ <tr>
533
+ <td><aaa></td>
534
+ <td>&lt;aaa&gt;</td>
535
+ </tr>
536
+ <tr>
537
+ <td>b&b</td>
538
+ <td>b&amp;b</td>
539
+ </tr>
540
+ <tr>
541
+ <td>"ccc"</td>
542
+ <td>&quot;ccc&quot;</td>
543
+ </tr>
544
+ </table>
545
+ <pre>
546
+ ! doubled characters
547
+ </pre>
548
+
549
+ ##
550
+ - name: headerfooter1
551
+ class: HeaderFooterEruby
552
+ options:
553
+ testopt: eval('ordered_list(list)')
554
+ input: |
555
+ <!--#header:
556
+ def ordered_list(list)
557
+ #-->
558
+ <ol>
559
+ <% for item in list %>
560
+ <li><%==item%></li>
561
+ <% end %>
562
+ </ol>
563
+ <!--#footer: end #-->
564
+ src: |4
565
+
566
+ def ordered_list(list)
567
+
568
+ _buf = ''; _buf << '<ol>
569
+ '; for item in list
570
+ _buf << ' <li>'; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '</li>
571
+ '; end
572
+ _buf << '</ol>
573
+ ';
574
+ _buf.to_s
575
+ end
576
+ output: |
577
+ <ol>
578
+ <li>&lt;aaa&gt;</li>
579
+ <li>b&amp;b</li>
580
+ <li>&quot;ccc&quot;</li>
581
+ </ol>
582
+
583
+ ##
584
+ - name: deleteindent1
585
+ class: DeleteIndentEruby
586
+ options:
587
+ testopt:
588
+ input: *basic1_input
589
+ src: |
590
+ _buf = ''; _buf << '<ul>
591
+ '; for item in list
592
+ _buf << '<li>'; _buf << ( item ).to_s; _buf << '</li>
593
+ '; end
594
+ _buf << '</ul>
595
+ ';
596
+ _buf.to_s
597
+ output: |
598
+ <ul>
599
+ <li><aaa></li>
600
+ <li>b&b</li>
601
+ <li>"ccc"</li>
602
+ </ul>
603
+
604
+ ##
605
+ - name: interpolation1
606
+ class: InterpolationEruby
607
+ options:
608
+ testopt:
609
+ input: *basic1_input
610
+ src: |
611
+ _buf = ''; _buf << %Q`<ul>\n`
612
+ for item in list
613
+ _buf << %Q` <li>#{ item }</li>\n`
614
+ end
615
+ _buf << %Q`</ul>\n`
616
+ _buf.to_s
617
+ output: *basic1_output
618
+
619
+ - name: interpolation2
620
+ desc: sharp, back-quote, and backslash should be escaped, but other quotes should not be escaped (reported by andrewj)
621
+ class: InterpolationEruby
622
+ options:
623
+ testopt:
624
+ input: |
625
+ <p>`back-quote`</p>
626
+ <p><%= `echo back-tick operator` %></p>
627
+ <p>#{sharp}</p>
628
+ <p>'single quote'</p>
629
+ <p>"double quote"</p>
630
+ <p>backslash\n\t</p>
631
+ src: |
632
+ _buf = ''; _buf << %Q`<p>\`back-quote\`</p>
633
+ <p>#{ `echo back-tick operator` }</p>
634
+ <p>\#{sharp}</p>
635
+ <p>'single quote'</p>
636
+ <p>"double quote"</p>
637
+ <p>backslash\\n\\t</p>\n`
638
+ _buf.to_s
639
+ output: |
640
+ <p>`back-quote`</p>
641
+ <p>back-tick operator
642
+ </p>
643
+ <p>#{sharp}</p>
644
+ <p>'single quote'</p>
645
+ <p>"double quote"</p>
646
+ <p>backslash\n\t</p>