erubis 2.1.0 → 2.2.0
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/{ChangeLog → CHANGES} +139 -6
- data/MIT-LICENSE +20 -0
- data/README.txt +20 -5
- data/benchmark/erubybench.rb +465 -229
- data/benchmark/erubybench.rhtml +39 -15
- data/benchmark/erubybench.yaml +126 -46
- data/bin/erubis +2 -2
- data/bin/notext +3 -3
- data/contrib/action_view_base_rb.patch +23 -0
- data/contrib/erubis +466 -308
- data/contrib/inline-require +2 -2
- data/doc-api/classes/ERB.html +101 -0
- data/doc-api/classes/Erubis.html +59 -6
- data/doc-api/classes/Erubis/ArrayEnhancer.html +12 -12
- data/doc-api/classes/Erubis/Basic/Converter.html +61 -57
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
- data/doc-api/classes/Erubis/CGenerator.html +60 -60
- data/doc-api/classes/Erubis/Context.html +125 -29
- data/doc-api/classes/Erubis/Converter.html +73 -22
- data/doc-api/classes/Erubis/Engine.html +55 -39
- data/doc-api/classes/Erubis/EscapeEnhancer.html +6 -6
- data/doc-api/classes/Erubis/Evaluator.html +19 -19
- data/doc-api/classes/Erubis/Generator.html +16 -10
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +14 -14
- data/doc-api/classes/Erubis/{Helper.html → Helpers.html} +5 -6
- data/doc-api/classes/Erubis/Helpers/RailsHelper.html +296 -0
- data/doc-api/classes/Erubis/JavaGenerator.html +54 -54
- data/doc-api/classes/Erubis/JavascriptGenerator.html +60 -60
- data/doc-api/classes/Erubis/Main.html +42 -30
- data/doc-api/classes/Erubis/NoCodeEnhancer.html +5 -5
- data/doc-api/classes/Erubis/NoTextEnhancer.html +7 -7
- data/doc-api/classes/Erubis/OptimizedEruby.html +6 -6
- data/doc-api/classes/Erubis/OptimizedGenerator.html +72 -72
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +6 -6
- data/doc-api/classes/Erubis/PI/Converter.html +28 -81
- data/doc-api/classes/Erubis/PI/Ec.html +6 -6
- data/doc-api/classes/Erubis/PI/Ejava.html +6 -6
- data/doc-api/classes/Erubis/PI/Ejavascript.html +6 -6
- data/doc-api/classes/Erubis/PI/Eperl.html +6 -6
- data/doc-api/classes/Erubis/PI/Ephp.html +6 -6
- data/doc-api/classes/Erubis/PI/Eruby.html +7 -7
- data/doc-api/classes/Erubis/PI/Escheme.html +6 -6
- data/doc-api/classes/Erubis/PI/TinyEruby.html +66 -79
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +8 -8
- data/doc-api/classes/Erubis/PerlGenerator.html +54 -54
- data/doc-api/classes/Erubis/PhpGenerator.html +54 -54
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +21 -21
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +30 -30
- data/doc-api/classes/Erubis/RubyEvaluator.html +12 -12
- data/doc-api/classes/Erubis/RubyGenerator.html +9 -9
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +7 -6
- data/doc-api/classes/Erubis/StdoutEnhancer.html +12 -12
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +13 -13
- data/doc-api/classes/Erubis/TinyEruby.html +56 -68
- data/doc-api/classes/Erubis/XmlHelper.html +20 -23
- data/doc-api/created.rid +1 -1
- data/doc-api/files/{__/README_txt.html → README_txt.html} +35 -20
- data/doc-api/files/erubis/context_rb.html +2 -2
- data/doc-api/files/erubis/converter_rb.html +2 -2
- data/doc-api/files/erubis/engine/ec_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
- data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
- data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
- data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
- data/doc-api/files/erubis/engine/eruby_rb.html +2 -3
- data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
- data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
- data/doc-api/files/erubis/engine_rb.html +2 -2
- data/doc-api/files/erubis/enhancer_rb.html +2 -2
- data/doc-api/files/erubis/error_rb.html +2 -2
- data/doc-api/files/erubis/evaluator_rb.html +2 -2
- data/doc-api/files/erubis/generator_rb.html +2 -2
- data/doc-api/files/erubis/helper_rb.html +2 -2
- data/doc-api/files/erubis/{helper/rails_rb.html → helpers/rails_helper_rb.html} +6 -31
- data/doc-api/files/erubis/local-setting_rb.html +2 -2
- data/doc-api/files/erubis/main_rb.html +4 -2
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +3 -3
- data/doc-api/fr_file_index.html +2 -2
- data/doc-api/fr_method_index.html +142 -147
- data/doc-api/index.html +1 -1
- data/doc/users-guide.html +387 -218
- data/lib/erubis.rb +21 -25
- data/lib/erubis/context.rb +34 -4
- data/lib/erubis/converter.rb +159 -115
- data/lib/erubis/engine.rb +29 -12
- data/lib/erubis/engine/ec.rb +2 -2
- data/lib/erubis/engine/ejava.rb +2 -2
- data/lib/erubis/engine/ejavascript.rb +2 -2
- data/lib/erubis/engine/enhanced.rb +2 -2
- data/lib/erubis/engine/eperl.rb +2 -2
- data/lib/erubis/engine/ephp.rb +2 -2
- data/lib/erubis/engine/eruby.rb +5 -6
- data/lib/erubis/engine/escheme.rb +2 -2
- data/lib/erubis/engine/optimized.rb +2 -2
- data/lib/erubis/enhancer.rb +33 -7
- data/lib/erubis/error.rb +2 -2
- data/lib/erubis/evaluator.rb +2 -2
- data/lib/erubis/generator.rb +6 -3
- data/lib/erubis/helper.rb +6 -23
- data/lib/erubis/helpers/rails_helper.rb +202 -0
- data/lib/erubis/local-setting.rb +4 -4
- data/lib/erubis/main.rb +90 -35
- data/lib/erubis/tiny.rb +57 -52
- data/test/assert-text-equal.rb +2 -2
- data/test/test-engines.rb +5 -5
- data/test/test-erubis.rb +173 -63
- data/test/test-main.rb +135 -27
- data/test/test-notext.rb +2 -2
- data/test/test.rb +2 -2
- data/test/testutil.rb +2 -2
- metadata +16 -16
- data/LGPL +0 -504
- data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +0 -198
- data/doc-api/classes/Erubis/Helper/RailsTemplate.html +0 -366
- data/lib/erubis/helper/rails.rb +0 -159
data/contrib/inline-require
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
###
|
|
6
6
|
### usage: inline-require [-h] [-I path[,path2,..]] script
|
|
7
7
|
###
|
|
8
|
-
### copyright(c) 2006 kuwata-lab all rights reserved.
|
|
9
|
-
### $Release: 2.
|
|
8
|
+
### copyright(c) 2006-2007 kuwata-lab all rights reserved.
|
|
9
|
+
### $Release: 2.2.0 $
|
|
10
10
|
### $Rev: 2 $
|
|
11
11
|
###
|
|
12
12
|
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Module: ERB</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Module</strong></td>
|
|
53
|
+
<td class="class-name-in-header">ERB</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
</td>
|
|
59
|
+
</tr>
|
|
60
|
+
|
|
61
|
+
</table>
|
|
62
|
+
</div>
|
|
63
|
+
<!-- banner header -->
|
|
64
|
+
|
|
65
|
+
<div id="bodyContent">
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
<div id="contextContent">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<!-- if includes -->
|
|
80
|
+
|
|
81
|
+
<div id="section">
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
<!-- if method_list -->
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
<div id="validator-badges">
|
|
97
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
</body>
|
|
101
|
+
</html>
|
data/doc-api/classes/Erubis.html
CHANGED
|
@@ -118,14 +118,14 @@
|
|
|
118
118
|
<a href="../files/erubis/generator_rb.html">
|
|
119
119
|
erubis/generator.rb
|
|
120
120
|
</a>
|
|
121
|
-
<br />
|
|
122
|
-
<a href="../files/erubis/helper/rails_rb.html">
|
|
123
|
-
erubis/helper/rails.rb
|
|
124
|
-
</a>
|
|
125
121
|
<br />
|
|
126
122
|
<a href="../files/erubis/helper_rb.html">
|
|
127
123
|
erubis/helper.rb
|
|
128
124
|
</a>
|
|
125
|
+
<br />
|
|
126
|
+
<a href="../files/erubis/helpers/rails_helper_rb.html">
|
|
127
|
+
erubis/helpers/rails_helper.rb
|
|
128
|
+
</a>
|
|
129
129
|
<br />
|
|
130
130
|
<a href="../files/erubis/main_rb.html">
|
|
131
131
|
erubis/main.rb
|
|
@@ -134,6 +134,10 @@
|
|
|
134
134
|
<a href="../files/erubis/tiny_rb.html">
|
|
135
135
|
erubis/tiny.rb
|
|
136
136
|
</a>
|
|
137
|
+
<br />
|
|
138
|
+
<a href="../files/erubis_rb.html">
|
|
139
|
+
erubis.rb
|
|
140
|
+
</a>
|
|
137
141
|
<br />
|
|
138
142
|
</td>
|
|
139
143
|
</tr>
|
|
@@ -150,8 +154,52 @@
|
|
|
150
154
|
|
|
151
155
|
<div id="description">
|
|
152
156
|
<p>
|
|
153
|
-
|
|
157
|
+
an implementation of eRuby
|
|
154
158
|
</p>
|
|
159
|
+
<p>
|
|
160
|
+
ex.
|
|
161
|
+
</p>
|
|
162
|
+
<pre>
|
|
163
|
+
input = <<'END'
|
|
164
|
+
<ul>
|
|
165
|
+
<% for item in @list %>
|
|
166
|
+
<li><%= item %>
|
|
167
|
+
<%== item %></li>
|
|
168
|
+
<% end %>
|
|
169
|
+
</ul>
|
|
170
|
+
END
|
|
171
|
+
list = ['<aaa>', 'b&b', '"ccc"']
|
|
172
|
+
eruby = Erubis::Eruby.new(input)
|
|
173
|
+
puts "--- code ---"
|
|
174
|
+
puts eruby.src
|
|
175
|
+
puts "--- result ---"
|
|
176
|
+
context = Erubis::Context.new() # or new(:list=>list)
|
|
177
|
+
context[:list] = list
|
|
178
|
+
puts eruby.evaluate(context)
|
|
179
|
+
</pre>
|
|
180
|
+
<p>
|
|
181
|
+
result:
|
|
182
|
+
</p>
|
|
183
|
+
<pre>
|
|
184
|
+
--- source ---
|
|
185
|
+
_buf = ''; _buf << '<ul>
|
|
186
|
+
'; for item in @list
|
|
187
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '
|
|
188
|
+
'; _buf << ' '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</li>
|
|
189
|
+
'; end
|
|
190
|
+
_buf << '</ul>
|
|
191
|
+
';
|
|
192
|
+
_buf.to_s
|
|
193
|
+
--- result ---
|
|
194
|
+
<ul>
|
|
195
|
+
<li><aaa>
|
|
196
|
+
&lt;aaa&gt;</li>
|
|
197
|
+
<li>b&b
|
|
198
|
+
b&amp;b</li>
|
|
199
|
+
<li>"ccc"
|
|
200
|
+
&quot;ccc&quot;</li>
|
|
201
|
+
</ul>
|
|
202
|
+
</pre>
|
|
155
203
|
|
|
156
204
|
</div>
|
|
157
205
|
|
|
@@ -179,7 +227,7 @@ Module <a href="Erubis/EscapeEnhancer.html" class="link">Erubis::EscapeEnhancer<
|
|
|
179
227
|
Module <a href="Erubis/Evaluator.html" class="link">Erubis::Evaluator</a><br />
|
|
180
228
|
Module <a href="Erubis/Generator.html" class="link">Erubis::Generator</a><br />
|
|
181
229
|
Module <a href="Erubis/HeaderFooterEnhancer.html" class="link">Erubis::HeaderFooterEnhancer</a><br />
|
|
182
|
-
Module <a href="Erubis/
|
|
230
|
+
Module <a href="Erubis/Helpers.html" class="link">Erubis::Helpers</a><br />
|
|
183
231
|
Module <a href="Erubis/JavaGenerator.html" class="link">Erubis::JavaGenerator</a><br />
|
|
184
232
|
Module <a href="Erubis/JavascriptGenerator.html" class="link">Erubis::JavascriptGenerator</a><br />
|
|
185
233
|
Module <a href="Erubis/NoCodeEnhancer.html" class="link">Erubis::NoCodeEnhancer</a><br />
|
|
@@ -255,6 +303,11 @@ Class <a href="Erubis/XmlEruby.html" class="link">Erubis::XmlEruby</a><br />
|
|
|
255
303
|
<td>=</td>
|
|
256
304
|
<td class="context-item-value">EscapedEjavascript</td>
|
|
257
305
|
</tr>
|
|
306
|
+
<tr class="top-aligned-row context-row">
|
|
307
|
+
<td class="context-item-name">VERSION</td>
|
|
308
|
+
<td>=</td>
|
|
309
|
+
<td class="context-item-value">('$Release: 2.2.0 $' =~ /([.\d]+)/) && $1</td>
|
|
310
|
+
</tr>
|
|
258
311
|
</table>
|
|
259
312
|
</div>
|
|
260
313
|
</div>
|
|
@@ -89,8 +89,8 @@ this is only for <a href="Eruby.html">Eruby</a>.
|
|
|
89
89
|
<h3 class="section-bar">Methods</h3>
|
|
90
90
|
|
|
91
91
|
<div class="name-list">
|
|
92
|
-
<a href="#
|
|
93
|
-
<a href="#
|
|
92
|
+
<a href="#M000148">add_postamble</a>
|
|
93
|
+
<a href="#M000147">add_preamble</a>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
96
|
|
|
@@ -112,19 +112,19 @@ this is only for <a href="Eruby.html">Eruby</a>.
|
|
|
112
112
|
<div id="methods">
|
|
113
113
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
114
114
|
|
|
115
|
-
<div id="method-
|
|
116
|
-
<a name="
|
|
115
|
+
<div id="method-M000148" class="method-detail">
|
|
116
|
+
<a name="M000148"></a>
|
|
117
117
|
|
|
118
118
|
<div class="method-heading">
|
|
119
|
-
<a href="#
|
|
119
|
+
<a href="#M000148" class="method-signature">
|
|
120
120
|
<span class="method-name">add_postamble</span><span class="method-args">(src)</span>
|
|
121
121
|
</a>
|
|
122
122
|
</div>
|
|
123
123
|
|
|
124
124
|
<div class="method-description">
|
|
125
125
|
<p><a class="source-toggle" href="#"
|
|
126
|
-
onclick="toggleCode('
|
|
127
|
-
<div class="method-source-code" id="
|
|
126
|
+
onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
|
|
127
|
+
<div class="method-source-code" id="M000148-source">
|
|
128
128
|
<pre>
|
|
129
129
|
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 169</span>
|
|
130
130
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_postamble</span>(<span class="ruby-identifier">src</span>)
|
|
@@ -136,19 +136,19 @@ this is only for <a href="Eruby.html">Eruby</a>.
|
|
|
136
136
|
</div>
|
|
137
137
|
</div>
|
|
138
138
|
|
|
139
|
-
<div id="method-
|
|
140
|
-
<a name="
|
|
139
|
+
<div id="method-M000147" class="method-detail">
|
|
140
|
+
<a name="M000147"></a>
|
|
141
141
|
|
|
142
142
|
<div class="method-heading">
|
|
143
|
-
<a href="#
|
|
143
|
+
<a href="#M000147" class="method-signature">
|
|
144
144
|
<span class="method-name">add_preamble</span><span class="method-args">(src)</span>
|
|
145
145
|
</a>
|
|
146
146
|
</div>
|
|
147
147
|
|
|
148
148
|
<div class="method-description">
|
|
149
149
|
<p><a class="source-toggle" href="#"
|
|
150
|
-
onclick="toggleCode('
|
|
151
|
-
<div class="method-source-code" id="
|
|
150
|
+
onclick="toggleCode('M000147-source');return false;">[Source]</a></p>
|
|
151
|
+
<div class="method-source-code" id="M000147-source">
|
|
152
152
|
<pre>
|
|
153
153
|
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 165</span>
|
|
154
154
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_preamble</span>(<span class="ruby-identifier">src</span>)
|
|
@@ -86,10 +86,10 @@ basic converter which supports ’<% … %>’ notation.
|
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
|
87
87
|
|
|
88
88
|
<div class="name-list">
|
|
89
|
-
<a href="#
|
|
90
|
-
<a href="#
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
89
|
+
<a href="#M000054">add_expr</a>
|
|
90
|
+
<a href="#M000053">convert_input</a>
|
|
91
|
+
<a href="#M000051">init_converter</a>
|
|
92
|
+
<a href="#M000052">pattern_regexp</a>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
|
|
@@ -116,10 +116,12 @@ basic converter which supports ’<% … %>’ notation.
|
|
|
116
116
|
<tr class="top-aligned-row context-row">
|
|
117
117
|
<td class="context-item-name">DEFAULT_REGEXP</td>
|
|
118
118
|
<td>=</td>
|
|
119
|
-
<td class="context-item-value"
|
|
119
|
+
<td class="context-item-value">pattern_regexp('<% %>')</td>
|
|
120
120
|
<td width="3em"> </td>
|
|
121
121
|
<td class="context-item-desc">
|
|
122
122
|
DEFAULT_REGEXP = /(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
123
|
+
DEFAULT_REGEXP = /(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
124
|
+
DEFAULT_REGEXP = /<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
123
125
|
|
|
124
126
|
</td>
|
|
125
127
|
</tr>
|
|
@@ -154,11 +156,11 @@ DEFAULT_REGEXP = /(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
|
154
156
|
<div id="methods">
|
|
155
157
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
156
158
|
|
|
157
|
-
<div id="method-
|
|
158
|
-
<a name="
|
|
159
|
+
<div id="method-M000054" class="method-detail">
|
|
160
|
+
<a name="M000054"></a>
|
|
159
161
|
|
|
160
162
|
<div class="method-heading">
|
|
161
|
-
<a href="#
|
|
163
|
+
<a href="#M000054" class="method-signature">
|
|
162
164
|
<span class="method-name">add_expr</span><span class="method-args">(src, code, indicator)</span>
|
|
163
165
|
</a>
|
|
164
166
|
</div>
|
|
@@ -168,10 +170,10 @@ DEFAULT_REGEXP = /(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
|
168
170
|
add expression code to src
|
|
169
171
|
</p>
|
|
170
172
|
<p><a class="source-toggle" href="#"
|
|
171
|
-
onclick="toggleCode('
|
|
172
|
-
<div class="method-source-code" id="
|
|
173
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
|
174
|
+
<div class="method-source-code" id="M000054-source">
|
|
173
175
|
<pre>
|
|
174
|
-
<span class="ruby-comment cmt"># File erubis/converter.rb, line
|
|
176
|
+
<span class="ruby-comment cmt"># File erubis/converter.rb, line 171</span>
|
|
175
177
|
<span class="ruby-keyword kw">def</span> <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>)
|
|
176
178
|
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">indicator</span>
|
|
177
179
|
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'='</span>
|
|
@@ -187,53 +189,58 @@ add expression code to src
|
|
|
187
189
|
</div>
|
|
188
190
|
</div>
|
|
189
191
|
|
|
190
|
-
<div id="method-
|
|
191
|
-
<a name="
|
|
192
|
+
<div id="method-M000053" class="method-detail">
|
|
193
|
+
<a name="M000053"></a>
|
|
192
194
|
|
|
193
195
|
<div class="method-heading">
|
|
194
|
-
<a href="#
|
|
196
|
+
<a href="#M000053" class="method-signature">
|
|
195
197
|
<span class="method-name">convert_input</span><span class="method-args">(src, input)</span>
|
|
196
198
|
</a>
|
|
197
199
|
</div>
|
|
198
200
|
|
|
199
201
|
<div class="method-description">
|
|
200
202
|
<p><a class="source-toggle" href="#"
|
|
201
|
-
onclick="toggleCode('
|
|
202
|
-
<div class="method-source-code" id="
|
|
203
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
|
204
|
+
<div class="method-source-code" id="M000053-source">
|
|
203
205
|
<pre>
|
|
204
|
-
<span class="ruby-comment cmt"># File erubis/converter.rb, line
|
|
206
|
+
<span class="ruby-comment cmt"># File erubis/converter.rb, line 127</span>
|
|
205
207
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert_input</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">input</span>)
|
|
206
|
-
<span class="ruby-identifier">
|
|
208
|
+
<span class="ruby-identifier">pat</span> = <span class="ruby-ivar">@pattern</span>
|
|
209
|
+
<span class="ruby-identifier">regexp</span> = <span class="ruby-identifier">pat</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">pat</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'<% %>'</span> <span class="ruby-operator">?</span> <span class="ruby-constant">DEFAULT_REGEXP</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">pattern_regexp</span>(<span class="ruby-identifier">pat</span>)
|
|
207
210
|
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
|
208
|
-
<span class="ruby-identifier">
|
|
211
|
+
<span class="ruby-identifier">is_bol</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-comment cmt"># is beginning of line</span>
|
|
212
|
+
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">regexp</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">indicator</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">rspace</span><span class="ruby-operator">|</span>
|
|
209
213
|
<span class="ruby-identifier">match</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>()
|
|
210
|
-
<span class="ruby-identifier">
|
|
211
|
-
<span class="ruby-identifier">text</span>
|
|
212
|
-
<span class="ruby-identifier">pos</span>
|
|
213
|
-
<span class="ruby-identifier">
|
|
214
|
+
<span class="ruby-identifier">len</span> = <span class="ruby-identifier">match</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>
|
|
215
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">len</span>]
|
|
216
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">match</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
|
217
|
+
<span class="ruby-identifier">ch</span> = <span class="ruby-identifier">indicator</span> <span class="ruby-value">? </span><span class="ruby-identifier">indicator</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
|
218
|
+
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value">?=</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">detect_spaces_at_bol</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">is_bol</span>)
|
|
219
|
+
<span class="ruby-identifier">is_bol</span> = <span class="ruby-identifier">rspace</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
|
220
|
+
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">text</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
|
214
221
|
<span class="ruby-comment cmt">## * when '<%= %>', do nothing</span>
|
|
215
222
|
<span class="ruby-comment cmt">## * when '<% %>' or '<%# %>', delete spaces iff only spaces are around '<% %>'</span>
|
|
216
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-
|
|
223
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value">?=</span> <span class="ruby-comment cmt"># <%= %></span>
|
|
224
|
+
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">lspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
|
225
|
+
<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>)
|
|
226
|
+
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>
|
|
227
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">ch</span> <span class="ruby-operator">==</span> <span class="ruby-value">?\#</span> <span class="ruby-comment cmt"># <%# %></span>
|
|
228
|
+
<span class="ruby-identifier">n</span> = <span class="ruby-identifier">code</span>.<span class="ruby-identifier">count</span>(<span class="ruby-value str">"\n"</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">rspace</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)
|
|
217
229
|
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@trim</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">lspace</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">rspace</span>
|
|
218
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-
|
|
230
|
+
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-value str">"\n"</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">n</span>)
|
|
219
231
|
<span class="ruby-keyword kw">else</span>
|
|
220
232
|
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">lspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
|
221
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">
|
|
233
|
+
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-value str">"\n"</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">n</span>)
|
|
222
234
|
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>
|
|
223
235
|
<span class="ruby-keyword kw">end</span>
|
|
224
|
-
<span class="ruby-keyword kw">
|
|
225
|
-
<span class="ruby-identifier">n</span> = <span class="ruby-identifier">code</span>.<span class="ruby-identifier">count</span>(<span class="ruby-value str">"\n"</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">rspace</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)
|
|
236
|
+
<span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># <% %></span>
|
|
226
237
|
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@trim</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">lspace</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">rspace</span>
|
|
227
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-
|
|
238
|
+
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-node">"#{lspace}#{code}#{rspace}"</span>)
|
|
228
239
|
<span class="ruby-keyword kw">else</span>
|
|
229
240
|
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">lspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
|
230
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-
|
|
241
|
+
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
|
|
231
242
|
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>
|
|
232
243
|
<span class="ruby-keyword kw">end</span>
|
|
233
|
-
<span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># <%= %></span>
|
|
234
|
-
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">lspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
|
235
|
-
<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>)
|
|
236
|
-
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>
|
|
237
244
|
<span class="ruby-keyword kw">end</span>
|
|
238
245
|
<span class="ruby-keyword kw">end</span>
|
|
239
246
|
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">$'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">input</span> <span class="ruby-comment cmt"># add input when no matched</span>
|
|
@@ -244,25 +251,25 @@ add expression code to src
|
|
|
244
251
|
</div>
|
|
245
252
|
</div>
|
|
246
253
|
|
|
247
|
-
<div id="method-
|
|
248
|
-
<a name="
|
|
254
|
+
<div id="method-M000051" class="method-detail">
|
|
255
|
+
<a name="M000051"></a>
|
|
249
256
|
|
|
250
257
|
<div class="method-heading">
|
|
251
|
-
<a href="#
|
|
258
|
+
<a href="#M000051" class="method-signature">
|
|
252
259
|
<span class="method-name">init_converter</span><span class="method-args">(properties={})</span>
|
|
253
260
|
</a>
|
|
254
261
|
</div>
|
|
255
262
|
|
|
256
263
|
<div class="method-description">
|
|
257
264
|
<p><a class="source-toggle" href="#"
|
|
258
|
-
onclick="toggleCode('
|
|
259
|
-
<div class="method-source-code" id="
|
|
265
|
+
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
|
266
|
+
<div class="method-source-code" id="M000051-source">
|
|
260
267
|
<pre>
|
|
261
|
-
<span class="ruby-comment cmt"># File erubis/converter.rb, line
|
|
268
|
+
<span class="ruby-comment cmt"># File erubis/converter.rb, line 103</span>
|
|
262
269
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">init_converter</span>(<span class="ruby-identifier">properties</span>={})
|
|
263
270
|
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">properties</span>)
|
|
264
|
-
<span class="ruby-ivar">@pattern</span>
|
|
265
|
-
<span class="ruby-ivar">@trim</span>
|
|
271
|
+
<span class="ruby-ivar">@pattern</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:pattern</span>]
|
|
272
|
+
<span class="ruby-ivar">@trim</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:trim</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">false</span>
|
|
266
273
|
<span class="ruby-keyword kw">end</span>
|
|
267
274
|
</pre>
|
|
268
275
|
</div>
|
|
@@ -271,12 +278,12 @@ add expression code to src
|
|
|
271
278
|
|
|
272
279
|
<h3 class="section-bar">Protected Instance methods</h3>
|
|
273
280
|
|
|
274
|
-
<div id="method-
|
|
275
|
-
<a name="
|
|
281
|
+
<div id="method-M000052" class="method-detail">
|
|
282
|
+
<a name="M000052"></a>
|
|
276
283
|
|
|
277
284
|
<div class="method-heading">
|
|
278
|
-
<a href="#
|
|
279
|
-
<span class="method-name">pattern_regexp</span><span class="method-args">(pattern
|
|
285
|
+
<a href="#M000052" class="method-signature">
|
|
286
|
+
<span class="method-name">pattern_regexp</span><span class="method-args">(pattern)</span>
|
|
280
287
|
</a>
|
|
281
288
|
</div>
|
|
282
289
|
|
|
@@ -285,18 +292,15 @@ add expression code to src
|
|
|
285
292
|
return regexp of pattern to parse eRuby script
|
|
286
293
|
</p>
|
|
287
294
|
<p><a class="source-toggle" href="#"
|
|
288
|
-
onclick="toggleCode('
|
|
289
|
-
<div class="method-source-code" id="
|
|
295
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
|
296
|
+
<div class="method-source-code" id="M000052-source">
|
|
290
297
|
<pre>
|
|
291
|
-
<span class="ruby-comment cmt"># File erubis/converter.rb, line
|
|
292
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pattern_regexp</span>(<span class="ruby-identifier">pattern</span
|
|
293
|
-
<span class="ruby-
|
|
294
|
-
|
|
295
|
-
<span class="ruby-
|
|
296
|
-
|
|
297
|
-
<span class="ruby-comment cmt">#return /(.*?)(^[ \t]*)?#{prefix}(=+|\#)?(.*?)-?#{postfix}([ \t]*\r?\n)?/m</span>
|
|
298
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-node">/(^[ \t]*)?#{prefix}(=+|\#)?(.*?)-?#{postfix}([ \t]*\r?\n)?/</span><span class="ruby-identifier">m</span>
|
|
299
|
-
<span class="ruby-keyword kw">end</span>
|
|
298
|
+
<span class="ruby-comment cmt"># File erubis/converter.rb, line 112</span>
|
|
299
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pattern_regexp</span>(<span class="ruby-identifier">pattern</span>)
|
|
300
|
+
<span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">postfix</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">split</span>() <span class="ruby-comment cmt"># '<% %>' => '<%', '%>'</span>
|
|
301
|
+
<span class="ruby-comment cmt">#return /(.*?)(^[ \t]*)?#{prefix}(=+|\#)?(.*?)-?#{postfix}([ \t]*\r?\n)?/m</span>
|
|
302
|
+
<span class="ruby-comment cmt">#return /(^[ \t]*)?#{prefix}(=+|\#)?(.*?)-?#{postfix}([ \t]*\r?\n)?/m</span>
|
|
303
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-node">/#{prefix}(=+|-|\#)?(.*?)-?#{postfix}([ \t]*\r?\n)?/</span><span class="ruby-identifier">m</span>
|
|
300
304
|
<span class="ruby-keyword kw">end</span>
|
|
301
305
|
</pre>
|
|
302
306
|
</div>
|