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-enhancers.rb
DELETED
@@ -1,646 +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 '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
|
-
<aaa>
|
151
|
-
<aaa>
|
152
|
-
b&b
|
153
|
-
b&b
|
154
|
-
"ccc"
|
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> % <aaa>
|
419
|
-
<aaa> = <aaa>
|
420
|
-
b&b % b&b
|
421
|
-
b&b = b&b
|
422
|
-
"ccc" % "ccc"
|
423
|
-
"ccc" = "ccc"
|
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> % <aaa>
|
442
|
-
<aaa> = <aaa>
|
443
|
-
b&b % b&b
|
444
|
-
b&b = b&b
|
445
|
-
"ccc" % "ccc"
|
446
|
-
"ccc" = "ccc"
|
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><aaa></td>
|
485
|
-
</tr>
|
486
|
-
<tr>
|
487
|
-
<td>b&b</td>
|
488
|
-
<td>b&b</td>
|
489
|
-
</tr>
|
490
|
-
<tr>
|
491
|
-
<td>"ccc"</td>
|
492
|
-
<td>"ccc"</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><aaa></td>
|
535
|
-
</tr>
|
536
|
-
<tr>
|
537
|
-
<td>b&b</td>
|
538
|
-
<td>b&b</td>
|
539
|
-
</tr>
|
540
|
-
<tr>
|
541
|
-
<td>"ccc"</td>
|
542
|
-
<td>"ccc"</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><aaa></li>
|
579
|
-
<li>b&b</li>
|
580
|
-
<li>"ccc"</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>
|