erubis 2.6.1 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.txt +16 -2
- data/README.txt +2 -1
- data/benchmark/bench.rb +1 -1
- data/bin/erubis +1 -1
- data/contrib/erubis +1 -1
- data/contrib/inline-require +1 -1
- data/doc-api/classes/Erubis.html +1 -1
- data/doc-api/classes/Erubis/Basic/Converter.html +3 -2
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +6 -3
- data/doc-api/classes/Erubis/DeleteIndentEnhancer.html +1 -1
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +6 -3
- data/doc-api/classes/Erubis/InterpolationEnhancer.html +7 -6
- data/doc-api/classes/Erubis/Main.html +26 -26
- data/doc-api/classes/Erubis/PI/Converter.html +5 -4
- data/doc-api/classes/Erubis/PI/TinyEruby.html +6 -5
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +3 -2
- data/doc-api/classes/Erubis/RubyEvaluator.html +18 -13
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +2 -1
- data/doc-api/classes/Erubis/TinyEruby.html +4 -3
- data/doc-api/created.rid +1 -1
- data/doc-api/files/README_txt.html +4 -3
- data/doc-api/files/erubis/context_rb.html +1 -1
- data/doc-api/files/erubis/converter_rb.html +2 -2
- 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 +1 -1
- 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_form_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 +2 -2
- data/doc-api/files/erubis/preprocessing_rb.html +1 -1
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +1 -1
- data/doc/users-guide.html +13 -11
- data/lib/erubis.rb +2 -2
- data/lib/erubis/context.rb +1 -1
- data/lib/erubis/converter.rb +6 -4
- 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 +1 -1
- 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 +16 -7
- data/lib/erubis/error.rb +1 -1
- data/lib/erubis/evaluator.rb +17 -12
- data/lib/erubis/generator.rb +1 -1
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helpers/rails_form_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 +32 -31
- data/lib/erubis/preprocessing.rb +1 -1
- data/lib/erubis/tiny.rb +6 -4
- data/test/assert-text-equal.rb +1 -1
- data/test/assert-text-equal.rbc +0 -0
- data/test/data/users-guide/example1.rb +1 -0
- data/test/data/users-guide/main_program2.result +1 -1
- data/test/hoge.rb +5 -0
- data/test/test-engines.rb +5 -2
- data/test/test-engines.rbc +0 -0
- data/test/test-enhancers.rb +4 -2
- data/test/test-erubis.rb +11 -5
- data/test/test-erubis.rbc +0 -0
- data/test/test-main.rb +27 -6
- data/test/test-users-guide.rb +4 -2
- data/test/test-users-guide.rbc +0 -0
- data/test/test.rb +1 -1
- data/test/test.rbc +0 -0
- data/test/testutil.rb +29 -3
- data/test/testutil.rbc +0 -0
- metadata +9 -4
- data/lib/erubis/converter.rb: +0 -0
- data/test/data/users-guide/stderr.log +0 -3
@@ -165,7 +165,8 @@ DEFAULT_REGEXP = /(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
165
165
|
<span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">indicator</span>)
|
166
166
|
<span class="ruby-keyword kw">end</span>
|
167
167
|
<span class="ruby-keyword kw">end</span>
|
168
|
-
<span class="ruby-
|
168
|
+
<span class="ruby-comment cmt">#rest = $' || input # ruby1.8</span>
|
169
|
+
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">pos</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">input</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-comment cmt"># ruby1.9</span>
|
169
170
|
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rest</span>)
|
170
171
|
<span class="ruby-identifier">add_postamble</span>(<span class="ruby-identifier">src</span>)
|
171
172
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">src</span>
|
@@ -211,7 +211,8 @@ ex.
|
|
211
211
|
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << ("</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">").to_s;"</span>
|
212
212
|
<span class="ruby-keyword kw">end</span>
|
213
213
|
<span class="ruby-keyword kw">end</span>
|
214
|
-
<span class="ruby-
|
214
|
+
<span class="ruby-comment cmt">#rest = $' || input # ruby1.8</span>
|
215
|
+
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">pos</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">input</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-comment cmt"># ruby1.9</span>
|
215
216
|
<span class="ruby-comment cmt">#src << " _buf << '" << escape_text(rest) << "';"</span>
|
216
217
|
<span class="ruby-identifier">rest</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/['\\]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
217
218
|
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << '"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">rest</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"';"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">empty?</span>
|
@@ -237,7 +238,7 @@ ex.
|
|
237
238
|
onclick="toggleCode('M000203-source');return false;">[Source]</a></p>
|
238
239
|
<div class="method-source-code" id="M000203-source">
|
239
240
|
<pre>
|
240
|
-
<span class="ruby-comment cmt"># File erubis/tiny.rb, line
|
241
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 63</span>
|
241
242
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">_context</span>=<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>)
|
242
243
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
243
244
|
<span class="ruby-identifier">_obj</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
@@ -274,7 +275,7 @@ end
|
|
274
275
|
onclick="toggleCode('M000202-source');return false;">[Source]</a></p>
|
275
276
|
<div class="method-source-code" id="M000202-source">
|
276
277
|
<pre>
|
277
|
-
<span class="ruby-comment cmt"># File erubis/tiny.rb, line
|
278
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 59</span>
|
278
279
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">result</span>(<span class="ruby-identifier">_binding</span>=<span class="ruby-constant">TOPLEVEL_BINDING</span>)
|
279
280
|
<span class="ruby-identifier">eval</span> <span class="ruby-ivar">@src</span>, <span class="ruby-identifier">_binding</span>
|
280
281
|
<span class="ruby-keyword kw">end</span>
|
data/doc-api/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Fri,
|
1
|
+
Fri, 13 Jun 2008 08:04:36 +0900
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Fri Jun
|
59
|
+
<td>Fri Jun 13 08:04:35 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -71,7 +71,7 @@
|
|
71
71
|
<div id="description">
|
72
72
|
<h1>README</h1>
|
73
73
|
<table>
|
74
|
-
<tr><td valign="top">release:</td><td>2.6.
|
74
|
+
<tr><td valign="top">release:</td><td>2.6.2
|
75
75
|
|
76
76
|
</td></tr>
|
77
77
|
<tr><td valign="top">copyright:</td><td>copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
@@ -120,7 +120,8 @@ datafile
|
|
120
120
|
</ul>
|
121
121
|
<p>
|
122
122
|
<a href="../classes/Erubis.html">Erubis</a> is implemented in pure Ruby. It
|
123
|
-
requires Ruby 1.8 or higher.
|
123
|
+
requires Ruby 1.8 or higher. <a href="../classes/Erubis.html">Erubis</a>
|
124
|
+
now supports Ruby 1.9.
|
124
125
|
</p>
|
125
126
|
<p>
|
126
127
|
See doc/users-guide.html for details.
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Jun 12 20:22:02 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
|
-
$Rev:
|
73
|
+
$Rev: 115 $ $Release: 2.6.2 $ copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
74
74
|
</p>
|
75
75
|
|
76
76
|
</div>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Jun 12 20:22:02 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
|
-
$Rev:
|
73
|
+
$Rev: 115 $ $Release: 2.6.2 $ copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
74
74
|
</p>
|
75
75
|
|
76
76
|
</div>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Jun 12 20:22:02 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
|
-
$Rev:
|
73
|
+
$Rev: 115 $ $Release: 2.6.2 $ copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
74
74
|
</p>
|
75
75
|
|
76
76
|
</div>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Thu
|
59
|
+
<td>Thu Jun 12 21:08:47 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
|
-
$Rev:
|
73
|
+
$Rev: 116 $ $Release: 2.6.2 $ copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
74
74
|
</p>
|
75
75
|
|
76
76
|
</div>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Jun 12 20:22:02 +0900 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
|
-
$Rev:
|
73
|
+
$Rev: 115 $ $Release: 2.6.2 $ copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
74
74
|
</p>
|
75
75
|
|
76
76
|
</div>
|
data/doc/users-guide.html
CHANGED
@@ -14,10 +14,10 @@
|
|
14
14
|
|
15
15
|
<div align="left"><h1>Erubis Users' Guide</h1></div>
|
16
16
|
<div align="left">
|
17
|
-
last update: $Date: 2008-
|
17
|
+
last update: $Date: 2008-06-13 08:04:21 +0900 (Fri, 13 Jun 2008) $<br>
|
18
18
|
</div>
|
19
19
|
|
20
|
-
<p>release: 2.6.
|
20
|
+
<p>release: 2.6.2
|
21
21
|
</p>
|
22
22
|
<a name="preface"></a>
|
23
23
|
<h2 class="section1">Preface</h2>
|
@@ -51,6 +51,7 @@ It has the following features.
|
|
51
51
|
</li>
|
52
52
|
</ul>
|
53
53
|
<p>Erubis is implemented in pure Ruby. It requires Ruby 1.8 or higher.
|
54
|
+
Erubis now supports Ruby 1.9.
|
54
55
|
</p>
|
55
56
|
<a name="toc"></a>
|
56
57
|
<h3 class="section2">Table of Contents</h3>
|
@@ -256,6 +257,7 @@ puts <strong>eruby.src</strong> # print script source
|
|
256
257
|
puts "---------- result ----------"
|
257
258
|
list = ['aaa', 'bbb', 'ccc']
|
258
259
|
puts <strong>eruby.result(binding())</strong> # get result
|
260
|
+
## or puts eruby.result(<strong>:list=>list</strong>) # or pass Hash instead of Binding
|
259
261
|
|
260
262
|
## # or
|
261
263
|
## eruby = Erubis::Eruby.new
|
@@ -620,22 +622,22 @@ This means that data is passed into eRuby script via local variables when Eruby:
|
|
620
622
|
</p>
|
621
623
|
<div class="program_caption">
|
622
624
|
definition of result(binding) and evaluate(context)</div>
|
623
|
-
<pre class="program">def result(_binding)
|
625
|
+
<pre class="program">def result(_binding=TOPLEVEL_BINDING)
|
624
626
|
if _binding.is_a?(Hash)
|
625
627
|
# load hash data as local variable
|
626
628
|
_h = _binding
|
627
|
-
eval _h.keys.inject("") {|s,k| s << "#{k} = _h[#{k.inspect}];"}
|
628
629
|
_binding = binding()
|
630
|
+
eval _h.collect{|k,v| "#{k} = _h[#{k.inspect}];"}.join, _binding
|
629
631
|
end
|
630
632
|
return <strong>eval(@src, _binding)</strong>
|
631
633
|
end
|
632
634
|
|
633
|
-
def evaluate(_context)
|
635
|
+
def evaluate(_context=Erubis::Context.new)
|
634
636
|
if _context.is_a?(Hash)
|
635
637
|
# convert hash object to Context object
|
636
638
|
_hash = _context
|
637
639
|
_context = Erubis::Context.new
|
638
|
-
_hash.each {
|
640
|
+
_hash.each {|k, v| _context[k] = v }
|
639
641
|
end
|
640
642
|
return <strong>_context.instance_eval(@src)</strong>
|
641
643
|
end
|
@@ -2750,7 +2752,7 @@ Result:</div>
|
|
2750
2752
|
item = foo
|
2751
2753
|
item = bar
|
2752
2754
|
item = baz
|
2753
|
-
** debug: local variables=["x", "_buf"]
|
2755
|
+
** debug: local variables=["_context", "x", "_buf"]
|
2754
2756
|
** debug: x=1
|
2755
2757
|
</pre>
|
2756
2758
|
<br>
|
@@ -2984,8 +2986,8 @@ example of using NoCodeEnhancer with PHP file</div>
|
|
2984
2986
|
<p>Thanks Andrew R Jackson, he developed 'erubis-run.rb' which enables you to use Erubis with mod_ruby.
|
2985
2987
|
</p>
|
2986
2988
|
<ol type="1">
|
2987
|
-
<li>Copy 'erubis-2.6.
|
2988
|
-
<pre class="terminal">$ cd erubis-2.6.
|
2989
|
+
<li>Copy 'erubis-2.6.2/contrib/erubis-run.rb' to the 'RUBYLIBDIR/apache' directory (for example '/usr/local/lib/ruby/1.8/apache') which contains 'ruby-run.rb', 'eruby-run.rb', and so on.
|
2990
|
+
<pre class="terminal">$ cd erubis-2.6.2/
|
2989
2991
|
$ sudo copy contrib/erubis-run.rb /usr/local/lib/ruby/1.8/apache/
|
2990
2992
|
</pre>
|
2991
2993
|
</li>
|
@@ -3061,12 +3063,12 @@ p obj.render('world') #=> "hello world"
|
|
3061
3063
|
|
3062
3064
|
<a name="topics-benchmark"></a>
|
3063
3065
|
<h3 class="section2">Benchmark</h3>
|
3064
|
-
<p>A benchmark script is included in Erubis package at 'erubis-2.6.
|
3066
|
+
<p>A benchmark script is included in Erubis package at 'erubis-2.6.2/benchark/' directory.
|
3065
3067
|
Here is an example result of benchmark.
|
3066
3068
|
</p>
|
3067
3069
|
<div class="terminal_caption">
|
3068
3070
|
MacOS X 10.4 Tiger, Intel CoreDuo 1.83GHz, Ruby1.8.6, eruby1.0.5, gcc4.0.1</div>
|
3069
|
-
<pre class="terminal">$ cd erubis-2.6.
|
3071
|
+
<pre class="terminal">$ cd erubis-2.6.2/benchmark/
|
3070
3072
|
$ ruby bench.rb -n 10000 -m execute
|
3071
3073
|
*** ntimes=10000, testmode=execute
|
3072
3074
|
user system total real
|
data/lib/erubis.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
2
|
## $Rev: 99 $
|
3
|
-
## $Release: 2.6.
|
3
|
+
## $Release: 2.6.2 $
|
4
4
|
## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
module Erubis
|
51
|
-
VERSION = ('$Release: 2.6.
|
51
|
+
VERSION = ('$Release: 2.6.2 $' =~ /([.\d]+)/) && $1
|
52
52
|
end
|
53
53
|
|
54
54
|
require 'erubis/engine'
|