erubis 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +55 -2
- data/README.txt +1 -1
- data/benchmark/bench.rb +1 -1
- data/bin/erubis +1 -1
- data/contrib/erubis +57 -34
- data/contrib/inline-require +1 -1
- data/doc-api/classes/Erubis.html +6 -1
- data/doc-api/classes/Erubis/DeleteIndentEnhancer.html +1 -1
- data/doc-api/classes/Erubis/Evaluator.html +3 -3
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +2 -2
- data/doc-api/classes/Erubis/InterpolationEnhancer.html +5 -5
- data/doc-api/classes/Erubis/JavascriptGenerator.html +16 -11
- data/doc-api/classes/Erubis/PI/Ejavascript.html +1 -1
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +22 -18
- data/doc-api/classes/Erubis/RubyEvaluator.html +4 -4
- data/doc-api/created.rid +1 -1
- data/doc-api/files/README_txt.html +2 -2
- data/doc-api/files/erubis/context_rb.html +1 -1
- data/doc-api/files/erubis/converter_rb.html +1 -1
- data/doc-api/files/erubis/engine/ec_rb.html +1 -1
- data/doc-api/files/erubis/engine/ejava_rb.html +1 -1
- data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
- data/doc-api/files/erubis/engine/enhanced_rb.html +1 -1
- data/doc-api/files/erubis/engine/eperl_rb.html +1 -1
- data/doc-api/files/erubis/engine/ephp_rb.html +1 -1
- data/doc-api/files/erubis/engine/eruby_rb.html +1 -1
- data/doc-api/files/erubis/engine/escheme_rb.html +1 -1
- data/doc-api/files/erubis/engine/optimized_rb.html +1 -1
- data/doc-api/files/erubis/engine_rb.html +1 -1
- data/doc-api/files/erubis/enhancer_rb.html +2 -2
- data/doc-api/files/erubis/error_rb.html +1 -1
- data/doc-api/files/erubis/evaluator_rb.html +2 -2
- data/doc-api/files/erubis/generator_rb.html +1 -1
- data/doc-api/files/erubis/helper_rb.html +1 -1
- data/doc-api/files/erubis/helpers/rails_helper_rb.html +1 -1
- data/doc-api/files/erubis/local-setting_rb.html +1 -1
- data/doc-api/files/erubis/main_rb.html +1 -1
- data/doc-api/files/erubis/tiny_rb.html +1 -1
- data/doc-api/files/erubis_rb.html +1 -1
- data/doc/users-guide.html +126 -14
- data/lib/erubis.rb +2 -2
- data/lib/erubis/context.rb +1 -1
- data/lib/erubis/converter.rb +1 -1
- data/lib/erubis/engine.rb +1 -1
- data/lib/erubis/engine/ec.rb +1 -1
- data/lib/erubis/engine/ejava.rb +1 -1
- data/lib/erubis/engine/ejavascript.rb +9 -3
- data/lib/erubis/engine/enhanced.rb +1 -1
- data/lib/erubis/engine/eperl.rb +1 -1
- data/lib/erubis/engine/ephp.rb +1 -1
- data/lib/erubis/engine/eruby.rb +1 -1
- data/lib/erubis/engine/escheme.rb +1 -1
- data/lib/erubis/engine/optimized.rb +1 -1
- data/lib/erubis/enhancer.rb +23 -8
- data/lib/erubis/error.rb +1 -1
- data/lib/erubis/evaluator.rb +5 -3
- data/lib/erubis/generator.rb +1 -1
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helpers/rails_helper.rb +1 -1
- data/lib/erubis/local-setting.rb +1 -1
- data/lib/erubis/main.rb +1 -1
- data/lib/erubis/tiny.rb +1 -1
- data/test/assert-text-equal.rb +1 -1
- data/test/data/users-guide/main_program1.rb +8 -0
- data/test/data/users-guide/main_program1.result +6 -0
- data/test/data/users-guide/main_program2.rb +8 -0
- data/test/data/users-guide/main_program2.result +6 -0
- data/test/data/users-guide/stderr.log +3 -0
- data/test/data/users-guide/template1.rhtml +4 -0
- data/test/data/users-guide/template2.rhtml +4 -0
- data/test/test-engines.rb +29 -4
- data/test/test-enhancers.rb +4 -4
- data/test/test-erubis.rb +17 -2
- data/test/test-main.rb +2 -2
- data/test/test-users-guide.rb +1 -1
- data/test/test.rb +1 -1
- data/test/testutil.rb +1 -1
- metadata +9 -2
data/lib/erubis/error.rb
CHANGED
data/lib/erubis/evaluator.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.4.
|
2
|
+
## $Rev: 94 $
|
3
|
+
## $Release: 2.4.1 $
|
4
4
|
## copyright(c) 2006-2007 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -10,6 +10,8 @@ require 'erubis/context'
|
|
10
10
|
|
11
11
|
module Erubis
|
12
12
|
|
13
|
+
EMPTY_BINDING = binding()
|
14
|
+
|
13
15
|
|
14
16
|
##
|
15
17
|
## evaluate code
|
@@ -64,7 +66,7 @@ module Erubis
|
|
64
66
|
def evaluate(context=Context.new)
|
65
67
|
context = Context.new(context) if context.is_a?(Hash)
|
66
68
|
#return context.instance_eval(@src, @filename || '(erubis)')
|
67
|
-
@_proc ||= eval("proc { #{@src} }",
|
69
|
+
@_proc ||= eval("proc { #{@src} }", Erubis::EMPTY_BINDING, @filename || '(erubis)')
|
68
70
|
return context.instance_eval(&@_proc)
|
69
71
|
end
|
70
72
|
|
data/lib/erubis/generator.rb
CHANGED
data/lib/erubis/helper.rb
CHANGED
data/lib/erubis/local-setting.rb
CHANGED
data/lib/erubis/main.rb
CHANGED
data/lib/erubis/tiny.rb
CHANGED
data/test/assert-text-equal.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'erubis'
|
2
|
+
eruby = Erubis::Eruby.new(File.read('template1.rhtml'))
|
3
|
+
items = ['foo', 'bar', 'baz']
|
4
|
+
x = 1
|
5
|
+
## local variable 'x' and 'eruby' are passed to template as well as 'items'!
|
6
|
+
print eruby.result(binding())
|
7
|
+
## local variable 'x' is changed unintendedly because it is changed in template!
|
8
|
+
puts "** debug: x=#{x.inspect}" #=> "baz"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'erubis'
|
2
|
+
eruby = Erubis::Eruby.new(File.read('template2.rhtml'))
|
3
|
+
items = ['foo', 'bar', 'baz']
|
4
|
+
x = 1
|
5
|
+
## only 'items' are passed to template
|
6
|
+
print eruby.evaluate(:items=>items)
|
7
|
+
## local variable 'x' is not changed!
|
8
|
+
puts "** debug: x=#{x.inspect}" #=> 1
|
data/test/test-engines.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.4.
|
2
|
+
## $Rev: 95 $
|
3
|
+
## $Release: 2.4.1 $
|
4
4
|
## copyright(c) 2006-2007 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -298,11 +298,11 @@ __END__
|
|
298
298
|
'); print('*** debug: $i=', $i, "\n");print('
|
299
299
|
');
|
300
300
|
##
|
301
|
-
- name:
|
301
|
+
- name: javascript1
|
302
302
|
lang: javascript
|
303
303
|
class: Ejavascript
|
304
304
|
options:
|
305
|
-
input: |
|
305
|
+
input: &javascript_input |
|
306
306
|
<%
|
307
307
|
var user = 'Erubis';
|
308
308
|
var list = ['<aaa>', 'b&b', '"ccc"'];
|
@@ -340,3 +340,28 @@ __END__
|
|
340
340
|
alert("*** debug: i="+(i)); _buf.push("\n");
|
341
341
|
document.write(_buf.join(""));
|
342
342
|
##
|
343
|
+
- name: javascript2
|
344
|
+
lang: javascript
|
345
|
+
class: Ejavascript
|
346
|
+
options: { :docwrite: false }
|
347
|
+
input: *javascript_input
|
348
|
+
expected: |4
|
349
|
+
var _buf = [];
|
350
|
+
var user = 'Erubis';
|
351
|
+
var list = ['<aaa>', 'b&b', '"ccc"'];
|
352
|
+
|
353
|
+
_buf.push("<p>Hello "); _buf.push(user); _buf.push("!</p>\n\
|
354
|
+
<table>\n\
|
355
|
+
<tbody>\n");
|
356
|
+
var i;
|
357
|
+
for (i = 0; i < list.length; i++) {
|
358
|
+
_buf.push(" <tr bgcolor="); _buf.push(++i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); _buf.push("\">\n\
|
359
|
+
<td>"); _buf.push(i); _buf.push("</td>\n\
|
360
|
+
<td>"); _buf.push(list[i]); _buf.push("</td>\n\
|
361
|
+
</tr>\n");
|
362
|
+
}
|
363
|
+
_buf.push(" </tbody>\n\
|
364
|
+
</table>\n");
|
365
|
+
alert("*** debug: i="+(i)); _buf.push("\n");
|
366
|
+
_buf.join("");
|
367
|
+
##
|
data/test/test-enhancers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.4.
|
2
|
+
## $Rev: 93 $
|
3
|
+
## $Release: 2.4.1 $
|
4
4
|
## copyright(c) 2006-2007 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -471,8 +471,8 @@ __END__
|
|
471
471
|
'; end
|
472
472
|
_buf << '</table>
|
473
473
|
<pre>
|
474
|
-
|
475
|
-
|
474
|
+
% double percent
|
475
|
+
% spaced percent
|
476
476
|
</pre>
|
477
477
|
';
|
478
478
|
_buf.to_s
|
data/test/test-erubis.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.4.
|
2
|
+
## $Rev: 94 $
|
3
|
+
## $Release: 2.4.1 $
|
4
4
|
## copyright(c) 2006-2007 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -192,8 +192,23 @@ END
|
|
192
192
|
assert_nil(eruby.instance_variable_get('@_proc'))
|
193
193
|
end
|
194
194
|
|
195
|
+
#def test_toplevel_binding
|
196
|
+
# s = "locals = <%= local_variables().inspect %>\n<% x = 50 %>\n"
|
197
|
+
# eruby = Erubis::Eruby.new(s)
|
198
|
+
# _x = eval 'x', TOPLEVEL_BINDING
|
199
|
+
# _y = eval 'y', TOPLEVEL_BINDING
|
200
|
+
# actual = eruby.evaluate(:x=>_x, :y=>_y)
|
201
|
+
# _x = eval 'x', TOPLEVEL_BINDING
|
202
|
+
# _y = eval 'y', TOPLEVEL_BINDING
|
203
|
+
# puts "*** actual=#{actual.inspect}, x=#{_x.inspect}, y=#{_y.inspect}"
|
204
|
+
#end
|
205
|
+
|
195
206
|
end
|
196
207
|
|
208
|
+
x = 10
|
209
|
+
y = 20
|
210
|
+
|
211
|
+
|
197
212
|
__END__
|
198
213
|
- name: basic1
|
199
214
|
input: &basic1_input|
|
data/test/test-main.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
2
|
## $Rev: 87 $
|
3
|
-
## $Release: 2.4.
|
3
|
+
## $Release: 2.4.1 $
|
4
4
|
## $Date: 2007-07-12 05:01:24 +0900 (Thu, 12 Jul 2007) $
|
5
5
|
##
|
6
6
|
|
@@ -178,7 +178,7 @@ END
|
|
178
178
|
|
179
179
|
def test_version # -v
|
180
180
|
@options = '-v'
|
181
|
-
@expected = (("$Release: 2.4.
|
181
|
+
@expected = (("$Release: 2.4.1 $" =~ /[.\d]+/) && $&) + "\n"
|
182
182
|
@filename = false
|
183
183
|
_test()
|
184
184
|
end
|
data/test/test-users-guide.rb
CHANGED
data/test/test.rb
CHANGED
data/test/testutil.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: erubis
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 2.4.
|
7
|
-
date: 2007-
|
6
|
+
version: 2.4.1
|
7
|
+
date: 2007-09-25 00:00:00 +09:00
|
8
8
|
summary: a fast and extensible eRuby implementation which supports multi-language
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -153,6 +153,10 @@ files:
|
|
153
153
|
- test/data/users-guide/headerfooter_example.result
|
154
154
|
- test/data/users-guide/headerfooter_example2.result
|
155
155
|
- test/data/users-guide/interpolation_example.result
|
156
|
+
- test/data/users-guide/main_program1.rb
|
157
|
+
- test/data/users-guide/main_program1.result
|
158
|
+
- test/data/users-guide/main_program2.rb
|
159
|
+
- test/data/users-guide/main_program2.result
|
156
160
|
- test/data/users-guide/nocode-example.eruby
|
157
161
|
- test/data/users-guide/nocode-php.result
|
158
162
|
- test/data/users-guide/nocode_example.result
|
@@ -169,8 +173,11 @@ files:
|
|
169
173
|
- test/data/users-guide/printenabled-example.rb
|
170
174
|
- test/data/users-guide/printstatement_example.result
|
171
175
|
- test/data/users-guide/simplify_example.result
|
176
|
+
- test/data/users-guide/stderr.log
|
172
177
|
- test/data/users-guide/stdout_exmple.result
|
173
178
|
- test/data/users-guide/stringbuffer_example.result
|
179
|
+
- test/data/users-guide/template1.rhtml
|
180
|
+
- test/data/users-guide/template2.rhtml
|
174
181
|
- test/test-engines.rb
|
175
182
|
- test/test-enhancers.rb
|
176
183
|
- test/test-erubis.rb
|