erubis 2.0.1 → 2.1.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 +150 -2
- data/LGPL +504 -0
- data/README.txt +14 -8
- data/benchmark/erubybench.rb +1 -1
- data/benchmark/erubybench.rhtml +3 -3
- data/bin/erubis +1 -1
- data/bin/notext +154 -0
- data/contrib/erubis +1036 -374
- data/contrib/inline-require +5 -3
- data/doc-api/classes/Erubis.html +43 -1
- data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/ArrayEnhancer.html +14 -14
- data/doc-api/classes/Erubis/Basic.html +112 -0
- data/doc-api/classes/Erubis/Basic/Converter.html +318 -0
- data/doc-api/classes/Erubis/Basic/Engine.html +130 -0
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
- data/doc-api/classes/Erubis/CGenerator.html +386 -0
- data/doc-api/classes/Erubis/Context.html +31 -32
- data/doc-api/classes/Erubis/Converter.html +231 -0
- data/doc-api/classes/Erubis/Ec.html +9 -283
- data/doc-api/classes/Erubis/Ejava.html +9 -274
- data/doc-api/classes/Erubis/Ejavascript.html +9 -298
- data/doc-api/classes/Erubis/Engine.html +68 -508
- data/doc-api/classes/Erubis/Eperl.html +9 -259
- data/doc-api/classes/Erubis/Ephp.html +9 -239
- data/doc-api/classes/Erubis/ErubisError.html +2 -2
- data/doc-api/classes/Erubis/Eruby.html +4 -187
- data/doc-api/classes/Erubis/EscapeEnhancer.html +9 -11
- data/doc-api/classes/Erubis/Escheme.html +9 -272
- data/doc-api/classes/Erubis/Evaluator.html +212 -0
- data/doc-api/classes/Erubis/Generator.html +410 -0
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +16 -16
- data/doc-api/classes/Erubis/Helper.html +112 -0
- data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +198 -0
- data/doc-api/classes/Erubis/Helper/RailsTemplate.html +366 -0
- data/doc-api/classes/Erubis/JavaGenerator.html +359 -0
- data/doc-api/classes/Erubis/JavascriptGenerator.html +381 -0
- data/doc-api/classes/Erubis/Main.html +27 -25
- data/doc-api/classes/Erubis/NoCodeEnhancer.html +249 -0
- data/doc-api/classes/Erubis/NoCodeEruby.html +120 -0
- data/doc-api/classes/Erubis/NoTextEnhancer.html +8 -8
- data/doc-api/classes/Erubis/NotSupportedError.html +119 -0
- data/doc-api/classes/Erubis/OptimizedEruby.html +22 -304
- data/doc-api/classes/Erubis/OptimizedGenerator.html +439 -0
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +7 -7
- data/doc-api/classes/Erubis/PI.html +124 -0
- data/doc-api/classes/Erubis/PI/Converter.html +318 -0
- data/doc-api/classes/Erubis/PI/Ec.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejava.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejavascript.html +166 -0
- data/doc-api/classes/Erubis/PI/Engine.html +122 -0
- data/doc-api/classes/Erubis/PI/Eperl.html +166 -0
- data/doc-api/classes/Erubis/PI/Ephp.html +166 -0
- data/doc-api/classes/Erubis/PI/Eruby.html +155 -0
- data/doc-api/classes/Erubis/PI/Escheme.html +166 -0
- data/doc-api/classes/Erubis/PI/TinyEruby.html +305 -0
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +7 -7
- data/doc-api/classes/Erubis/PerlGenerator.html +344 -0
- data/doc-api/classes/Erubis/PhpGenerator.html +350 -0
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +24 -24
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +35 -35
- data/doc-api/classes/Erubis/RubyEvaluator.html +190 -0
- data/doc-api/classes/Erubis/RubyGenerator.html +327 -0
- data/doc-api/classes/Erubis/SchemeGenerator.html +382 -0
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +17 -13
- data/doc-api/classes/Erubis/StdoutEnhancer.html +14 -14
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/TinyEruby.html +45 -40
- data/doc-api/classes/Erubis/XmlHelper.html +14 -14
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +27 -9
- data/doc-api/files/erubis/context_rb.html +107 -0
- data/doc-api/files/erubis/converter_rb.html +114 -0
- 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 +3 -2
- 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 +6 -3
- data/doc-api/files/erubis/enhancer_rb.html +2 -9
- data/doc-api/files/erubis/error_rb.html +107 -0
- data/doc-api/files/erubis/evaluator_rb.html +115 -0
- data/doc-api/files/erubis/generator_rb.html +114 -0
- data/doc-api/files/erubis/helper/rails_rb.html +140 -0
- data/doc-api/files/erubis/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/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +32 -0
- data/doc-api/fr_file_index.html +6 -0
- data/doc-api/fr_method_index.html +178 -136
- data/doc/users-guide.html +538 -199
- data/examples/{Makefile → basic/Makefile} +11 -11
- data/examples/basic/example.ec +42 -0
- data/examples/{example.ejava → basic/example.ejava} +5 -1
- data/examples/{example.ejavascript → basic/example.ejs} +0 -0
- data/examples/{example.eperl → basic/example.eperl} +2 -2
- data/examples/{example.ephp → basic/example.ephp} +0 -0
- data/examples/{example.eruby → basic/example.eruby} +0 -0
- data/examples/{example.escheme → basic/example.escheme} +0 -0
- data/examples/pi/Makefile +54 -0
- data/examples/pi/example.ec +42 -0
- data/examples/pi/example.ejava +45 -0
- data/examples/pi/example.ejs +16 -0
- data/examples/pi/example.eperl +16 -0
- data/examples/pi/example.ephp +17 -0
- data/examples/pi/example.eruby +15 -0
- data/examples/pi/example.escheme +26 -0
- data/lib/erubis.rb +15 -8
- data/lib/erubis/context.rb +54 -0
- data/lib/erubis/converter.rb +307 -0
- data/lib/erubis/engine.rb +57 -227
- data/lib/erubis/engine/ec.rb +31 -20
- data/lib/erubis/engine/ejava.rb +33 -21
- data/lib/erubis/engine/ejavascript.rb +30 -18
- data/lib/erubis/engine/enhanced.rb +7 -2
- data/lib/erubis/engine/eperl.rb +33 -19
- data/lib/erubis/engine/ephp.rb +32 -14
- data/lib/erubis/engine/eruby.rb +34 -7
- data/lib/erubis/engine/escheme.rb +34 -15
- data/lib/erubis/engine/optimized.rb +25 -11
- data/lib/erubis/enhancer.rb +53 -19
- data/lib/erubis/error.rb +24 -0
- data/lib/erubis/evaluator.rb +71 -0
- data/lib/erubis/generator.rb +83 -0
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helper/rails.rb +159 -0
- data/lib/erubis/local-setting.rb +1 -1
- data/lib/erubis/main.rb +87 -46
- data/lib/erubis/tiny.rb +81 -7
- data/test/assert-text-equal.rb +1 -1
- data/test/test-engines.rb +8 -9
- data/test/test-erubis.rb +196 -18
- data/test/{test-bin.rb → test-main.rb} +123 -21
- data/test/test-notext.rb +27 -0
- data/test/test.rb +5 -3
- data/test/testutil.rb +25 -36
- metadata +75 -13
- data/COPYING +0 -340
- data/examples/example.ec +0 -24
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
|
|
81
81
|
<div id="description">
|
|
82
82
|
<p>
|
|
83
|
-
|
|
83
|
+
(abstract) abstract engine class. subclass must include evaluator and
|
|
84
|
+
converter module.
|
|
84
85
|
</p>
|
|
85
86
|
|
|
86
87
|
</div>
|
|
@@ -92,23 +93,11 @@
|
|
|
92
93
|
<h3 class="section-bar">Methods</h3>
|
|
93
94
|
|
|
94
95
|
<div class="name-list">
|
|
95
|
-
<a href="#
|
|
96
|
-
<a href="#
|
|
97
|
-
<a href="#
|
|
98
|
-
<a href="#
|
|
99
|
-
<a href="#
|
|
100
|
-
<a href="#M000072">add_preamble</a>
|
|
101
|
-
<a href="#M000074">add_stmt</a>
|
|
102
|
-
<a href="#M000073">add_text</a>
|
|
103
|
-
<a href="#M000068">compile</a>
|
|
104
|
-
<a href="#M000069">compile!</a>
|
|
105
|
-
<a href="#M000070">escape_text</a>
|
|
106
|
-
<a href="#M000071">escaped_expr</a>
|
|
107
|
-
<a href="#M000066">evaluate</a>
|
|
108
|
-
<a href="#M000064">load_file</a>
|
|
109
|
-
<a href="#M000063">new</a>
|
|
110
|
-
<a href="#M000067">pattern_regexp</a>
|
|
111
|
-
<a href="#M000065">result</a>
|
|
96
|
+
<a href="#M000165">convert!</a>
|
|
97
|
+
<a href="#M000167">load_file</a>
|
|
98
|
+
<a href="#M000166">new</a>
|
|
99
|
+
<a href="#M000168">process</a>
|
|
100
|
+
<a href="#M000169">process_proc</a>
|
|
112
101
|
</div>
|
|
113
102
|
</div>
|
|
114
103
|
|
|
@@ -120,40 +109,9 @@
|
|
|
120
109
|
<div id="section">
|
|
121
110
|
|
|
122
111
|
|
|
123
|
-
<div id="constants-list">
|
|
124
|
-
<h3 class="section-bar">Constants</h3>
|
|
125
|
-
|
|
126
|
-
<div class="name-list">
|
|
127
|
-
<table summary="Constants">
|
|
128
|
-
<tr class="top-aligned-row context-row">
|
|
129
|
-
<td class="context-item-name">DEFAULT_REGEXP</td>
|
|
130
|
-
<td>=</td>
|
|
131
|
-
<td class="context-item-value">/(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m</td>
|
|
132
|
-
</tr>
|
|
133
|
-
</table>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
112
|
|
|
138
113
|
|
|
139
|
-
<div id="attribute-list">
|
|
140
|
-
<h3 class="section-bar">Attributes</h3>
|
|
141
114
|
|
|
142
|
-
<div class="name-list">
|
|
143
|
-
<table>
|
|
144
|
-
<tr class="top-aligned-row context-row">
|
|
145
|
-
<td class="context-item-name">filename</td>
|
|
146
|
-
<td class="context-item-value"> [RW] </td>
|
|
147
|
-
<td class="context-item-desc"></td>
|
|
148
|
-
</tr>
|
|
149
|
-
<tr class="top-aligned-row context-row">
|
|
150
|
-
<td class="context-item-name">src</td>
|
|
151
|
-
<td class="context-item-value"> [R] </td>
|
|
152
|
-
<td class="context-item-desc"></td>
|
|
153
|
-
</tr>
|
|
154
|
-
</table>
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
115
|
|
|
158
116
|
|
|
159
117
|
|
|
@@ -161,11 +119,11 @@
|
|
|
161
119
|
<div id="methods">
|
|
162
120
|
<h3 class="section-bar">Public Class methods</h3>
|
|
163
121
|
|
|
164
|
-
<div id="method-
|
|
165
|
-
<a name="
|
|
122
|
+
<div id="method-M000167" class="method-detail">
|
|
123
|
+
<a name="M000167"></a>
|
|
166
124
|
|
|
167
125
|
<div class="method-heading">
|
|
168
|
-
<a href="#
|
|
126
|
+
<a href="#M000167" class="method-signature">
|
|
169
127
|
<span class="method-name">load_file</span><span class="method-args">(filename, properties={})</span>
|
|
170
128
|
</a>
|
|
171
129
|
</div>
|
|
@@ -175,10 +133,10 @@
|
|
|
175
133
|
load file and create engine object
|
|
176
134
|
</p>
|
|
177
135
|
<p><a class="source-toggle" href="#"
|
|
178
|
-
onclick="toggleCode('
|
|
179
|
-
<div class="method-source-code" id="
|
|
136
|
+
onclick="toggleCode('M000167-source');return false;">[Source]</a></p>
|
|
137
|
+
<div class="method-source-code" id="M000167-source">
|
|
180
138
|
<pre>
|
|
181
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line
|
|
139
|
+
<span class="ruby-comment cmt"># File erubis/engine.rb, line 40</span>
|
|
182
140
|
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">properties</span>={})
|
|
183
141
|
<span class="ruby-identifier">input</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value str">'rb'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span> }
|
|
184
142
|
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">untaint</span> <span class="ruby-comment cmt"># is it ok?</span>
|
|
@@ -191,30 +149,27 @@ load file and create engine object
|
|
|
191
149
|
</div>
|
|
192
150
|
</div>
|
|
193
151
|
|
|
194
|
-
<div id="method-
|
|
195
|
-
<a name="
|
|
152
|
+
<div id="method-M000166" class="method-detail">
|
|
153
|
+
<a name="M000166"></a>
|
|
196
154
|
|
|
197
155
|
<div class="method-heading">
|
|
198
|
-
<a href="#
|
|
199
|
-
<span class="method-name">new</span><span class="method-args">(input, properties={})</span>
|
|
156
|
+
<a href="#M000166" class="method-signature">
|
|
157
|
+
<span class="method-name">new</span><span class="method-args">(input=nil, properties={})</span>
|
|
200
158
|
</a>
|
|
201
159
|
</div>
|
|
202
160
|
|
|
203
161
|
<div class="method-description">
|
|
204
162
|
<p><a class="source-toggle" href="#"
|
|
205
|
-
onclick="toggleCode('
|
|
206
|
-
<div class="method-source-code" id="
|
|
163
|
+
onclick="toggleCode('M000166-source');return false;">[Source]</a></p>
|
|
164
|
+
<div class="method-source-code" id="M000166-source">
|
|
207
165
|
<pre>
|
|
208
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line
|
|
209
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">properties</span>={})
|
|
210
|
-
<span class="ruby-comment cmt">#@input
|
|
211
|
-
<span class="ruby-
|
|
212
|
-
<span class="ruby-
|
|
213
|
-
<span class="ruby-
|
|
214
|
-
<span class="ruby-ivar">@
|
|
215
|
-
<span class="ruby-ivar">@postamble</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:postamble</span>]
|
|
216
|
-
<span class="ruby-ivar">@escape</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:escape</span>]
|
|
217
|
-
<span class="ruby-ivar">@src</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">input</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">input</span>
|
|
166
|
+
<span class="ruby-comment cmt"># File erubis/engine.rb, line 31</span>
|
|
167
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">input</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>={})
|
|
168
|
+
<span class="ruby-comment cmt">#@input = input</span>
|
|
169
|
+
<span class="ruby-identifier">init_generator</span>(<span class="ruby-identifier">properties</span>)
|
|
170
|
+
<span class="ruby-identifier">init_converter</span>(<span class="ruby-identifier">properties</span>)
|
|
171
|
+
<span class="ruby-identifier">init_evaluator</span>(<span class="ruby-identifier">properties</span>)
|
|
172
|
+
<span class="ruby-ivar">@src</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">input</span>
|
|
218
173
|
<span class="ruby-keyword kw">end</span>
|
|
219
174
|
</pre>
|
|
220
175
|
</div>
|
|
@@ -223,201 +178,59 @@ load file and create engine object
|
|
|
223
178
|
|
|
224
179
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
225
180
|
|
|
226
|
-
<div id="method-
|
|
227
|
-
<a name="
|
|
228
|
-
|
|
229
|
-
<div class="method-heading">
|
|
230
|
-
<a href="#M000068" class="method-signature">
|
|
231
|
-
<span class="method-name">compile</span><span class="method-args">(input)</span>
|
|
232
|
-
</a>
|
|
233
|
-
</div>
|
|
234
|
-
|
|
235
|
-
<div class="method-description">
|
|
236
|
-
<p>
|
|
237
|
-
compile input string into target language
|
|
238
|
-
</p>
|
|
239
|
-
<p><a class="source-toggle" href="#"
|
|
240
|
-
onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
|
|
241
|
-
<div class="method-source-code" id="M000068-source">
|
|
242
|
-
<pre>
|
|
243
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 132</span>
|
|
244
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">input</span>)
|
|
245
|
-
<span class="ruby-identifier">src</span> = <span class="ruby-value str">""</span>
|
|
246
|
-
<span class="ruby-ivar">@preamble</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-identifier">add_preamble</span>(<span class="ruby-identifier">src</span>) <span class="ruby-operator">:</span> (<span class="ruby-ivar">@preamble</span> <span class="ruby-operator">&&</span> (<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@preamble</span>))
|
|
247
|
-
<span class="ruby-identifier">regexp</span> = <span class="ruby-identifier">pattern_regexp</span>(<span class="ruby-ivar">@pattern</span>)
|
|
248
|
-
<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">text</span>, <span class="ruby-identifier">lspace</span>, <span class="ruby-identifier">indicator</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">rspace</span><span class="ruby-operator">|</span>
|
|
249
|
-
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">text</span>)
|
|
250
|
-
<span class="ruby-comment cmt">## * when '<%= %>', do nothing</span>
|
|
251
|
-
<span class="ruby-comment cmt">## * when '<% %>' or '<%# %>', delete spaces iff only spaces are around '<% %>'</span>
|
|
252
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">indicator</span> <span class="ruby-comment cmt"># <% %></span>
|
|
253
|
-
<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>
|
|
254
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-node">"#{lspace}#{code}#{rspace}"</span>)
|
|
255
|
-
<span class="ruby-keyword kw">else</span>
|
|
256
|
-
<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>
|
|
257
|
-
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
|
|
258
|
-
<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>
|
|
259
|
-
<span class="ruby-keyword kw">end</span>
|
|
260
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">indicator</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\#</span> <span class="ruby-comment cmt"># <%# %></span>
|
|
261
|
-
<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>)
|
|
262
|
-
<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>
|
|
263
|
-
<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>)
|
|
264
|
-
<span class="ruby-keyword kw">else</span>
|
|
265
|
-
<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>
|
|
266
|
-
<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>)
|
|
267
|
-
<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>
|
|
268
|
-
<span class="ruby-keyword kw">end</span>
|
|
269
|
-
<span class="ruby-comment cmt">#flag_trim = @trim && lspace && rspace</span>
|
|
270
|
-
<span class="ruby-comment cmt">#add_text(src, lspace) if !flag_trim && lspace</span>
|
|
271
|
-
<span class="ruby-comment cmt">#n = code.count("\n") + (rspace ? 1 : 0)</span>
|
|
272
|
-
<span class="ruby-comment cmt">#add_stmt(src, "\n" * n)</span>
|
|
273
|
-
<span class="ruby-comment cmt">#add_text(src, rspace) if !flag_trim && rspace</span>
|
|
274
|
-
<span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># <%= %></span>
|
|
275
|
-
<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>
|
|
276
|
-
<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>)
|
|
277
|
-
<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>
|
|
278
|
-
<span class="ruby-keyword kw">end</span>
|
|
279
|
-
<span class="ruby-comment cmt">#if indicator && indicator[0] == ?=</span>
|
|
280
|
-
<span class="ruby-comment cmt"># flag_trim = false</span>
|
|
281
|
-
<span class="ruby-comment cmt">#else</span>
|
|
282
|
-
<span class="ruby-comment cmt"># flag_trim = @trim && lspace && rspace</span>
|
|
283
|
-
<span class="ruby-comment cmt">#end</span>
|
|
284
|
-
<span class="ruby-comment cmt">##flag_trim = @trim && !(indicator && indicator[0]==?=) && lspace && rspace</span>
|
|
285
|
-
<span class="ruby-comment cmt">#add_text(src, text)</span>
|
|
286
|
-
<span class="ruby-comment cmt">#add_text(src, lspace) if !flag_trim && lspace</span>
|
|
287
|
-
<span class="ruby-comment cmt">#if !indicator # <% %></span>
|
|
288
|
-
<span class="ruby-comment cmt"># code = "#{lspace}#{code}#{rspace}" if flag_trim</span>
|
|
289
|
-
<span class="ruby-comment cmt"># add_stmt(src, code)</span>
|
|
290
|
-
<span class="ruby-comment cmt">#elsif indicator[0] == ?\# # <%# %></span>
|
|
291
|
-
<span class="ruby-comment cmt"># n = code.count("\n") + (rspace ? 1 : 0)</span>
|
|
292
|
-
<span class="ruby-comment cmt"># add_stmt(src, "\n" * n)</span>
|
|
293
|
-
<span class="ruby-comment cmt">#else # <%= %></span>
|
|
294
|
-
<span class="ruby-comment cmt"># add_expr(src, code, indicator)</span>
|
|
295
|
-
<span class="ruby-comment cmt">#end</span>
|
|
296
|
-
<span class="ruby-comment cmt">#add_text(src, rspace) if !flag_trim && rspace</span>
|
|
297
|
-
<span class="ruby-keyword kw">end</span>
|
|
298
|
-
<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>
|
|
299
|
-
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rest</span>)
|
|
300
|
-
<span class="ruby-ivar">@postamble</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-identifier">add_postamble</span>(<span class="ruby-identifier">src</span>) <span class="ruby-operator">:</span> (<span class="ruby-ivar">@postamble</span> <span class="ruby-operator">&&</span> (<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@postamble</span>))
|
|
301
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">src</span>
|
|
302
|
-
<span class="ruby-keyword kw">end</span>
|
|
303
|
-
</pre>
|
|
304
|
-
</div>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
|
|
308
|
-
<div id="method-M000069" class="method-detail">
|
|
309
|
-
<a name="M000069"></a>
|
|
310
|
-
|
|
311
|
-
<div class="method-heading">
|
|
312
|
-
<a href="#M000069" class="method-signature">
|
|
313
|
-
<span class="method-name">compile!</span><span class="method-args">(input)</span>
|
|
314
|
-
</a>
|
|
315
|
-
</div>
|
|
316
|
-
|
|
317
|
-
<div class="method-description">
|
|
318
|
-
<p>
|
|
319
|
-
compile input string and set it to @src
|
|
320
|
-
</p>
|
|
321
|
-
<p><a class="source-toggle" href="#"
|
|
322
|
-
onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
|
|
323
|
-
<div class="method-source-code" id="M000069-source">
|
|
324
|
-
<pre>
|
|
325
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 193</span>
|
|
326
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile!</span>(<span class="ruby-identifier">input</span>)
|
|
327
|
-
<span class="ruby-ivar">@src</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">input</span>)
|
|
328
|
-
<span class="ruby-keyword kw">end</span>
|
|
329
|
-
</pre>
|
|
330
|
-
</div>
|
|
331
|
-
</div>
|
|
332
|
-
</div>
|
|
333
|
-
|
|
334
|
-
<div id="method-M000066" class="method-detail">
|
|
335
|
-
<a name="M000066"></a>
|
|
336
|
-
|
|
337
|
-
<div class="method-heading">
|
|
338
|
-
<a href="#M000066" class="method-signature">
|
|
339
|
-
<span class="method-name">evaluate</span><span class="method-args">(context=Context.new)</span>
|
|
340
|
-
</a>
|
|
341
|
-
</div>
|
|
342
|
-
|
|
343
|
-
<div class="method-description">
|
|
344
|
-
<p>
|
|
345
|
-
invoke context.instance_eval(@src)
|
|
346
|
-
</p>
|
|
347
|
-
<p><a class="source-toggle" href="#"
|
|
348
|
-
onclick="toggleCode('M000066-source');return false;">[Source]</a></p>
|
|
349
|
-
<div class="method-source-code" id="M000066-source">
|
|
350
|
-
<pre>
|
|
351
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 113</span>
|
|
352
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">context</span>=<span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>)
|
|
353
|
-
<span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>) <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>)
|
|
354
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-ivar">@src</span>, (<span class="ruby-ivar">@filename</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'(erubis)'</span>))
|
|
355
|
-
<span class="ruby-keyword kw">end</span>
|
|
356
|
-
</pre>
|
|
357
|
-
</div>
|
|
358
|
-
</div>
|
|
359
|
-
</div>
|
|
360
|
-
|
|
361
|
-
<div id="method-M000065" class="method-detail">
|
|
362
|
-
<a name="M000065"></a>
|
|
181
|
+
<div id="method-M000165" class="method-detail">
|
|
182
|
+
<a name="M000165"></a>
|
|
363
183
|
|
|
364
184
|
<div class="method-heading">
|
|
365
|
-
<a href="#
|
|
366
|
-
<span class="method-name">
|
|
185
|
+
<a href="#M000165" class="method-signature">
|
|
186
|
+
<span class="method-name">convert!</span><span class="method-args">(input)</span>
|
|
367
187
|
</a>
|
|
368
188
|
</div>
|
|
369
189
|
|
|
370
190
|
<div class="method-description">
|
|
371
191
|
<p>
|
|
372
|
-
|
|
192
|
+
convert input string and set it to @src
|
|
373
193
|
</p>
|
|
374
194
|
<p><a class="source-toggle" href="#"
|
|
375
|
-
onclick="toggleCode('
|
|
376
|
-
<div class="method-source-code" id="
|
|
195
|
+
onclick="toggleCode('M000165-source');return false;">[Source]</a></p>
|
|
196
|
+
<div class="method-source-code" id="M000165-source">
|
|
377
197
|
<pre>
|
|
378
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line
|
|
379
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
|
380
|
-
<span class="ruby-
|
|
381
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
|
382
|
-
<span class="ruby-comment cmt">## load _context data as local variables by eval</span>
|
|
383
|
-
<span class="ruby-identifier">eval</span> <span class="ruby-identifier">_arg</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value str">""</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{k.to_s} = _arg[#{k.inspect}];"</span> }
|
|
384
|
-
<span class="ruby-identifier">_arg</span> = <span class="ruby-identifier">binding</span>()
|
|
385
|
-
<span class="ruby-keyword kw">end</span>
|
|
386
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">eval</span>(<span class="ruby-ivar">@src</span>, <span class="ruby-identifier">_arg</span>, (<span class="ruby-ivar">@filename</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'(erubis)'</span>))
|
|
198
|
+
<span class="ruby-comment cmt"># File erubis/engine.rb, line 27</span>
|
|
199
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert!</span>(<span class="ruby-identifier">input</span>)
|
|
200
|
+
<span class="ruby-ivar">@src</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>)
|
|
387
201
|
<span class="ruby-keyword kw">end</span>
|
|
388
202
|
</pre>
|
|
389
203
|
</div>
|
|
390
204
|
</div>
|
|
391
205
|
</div>
|
|
392
206
|
|
|
393
|
-
<
|
|
394
|
-
|
|
395
|
-
<div id="method-M000075" class="method-detail">
|
|
396
|
-
<a name="M000075"></a>
|
|
207
|
+
<div id="method-M000168" class="method-detail">
|
|
208
|
+
<a name="M000168"></a>
|
|
397
209
|
|
|
398
210
|
<div class="method-heading">
|
|
399
|
-
<a href="#
|
|
400
|
-
<span class="method-name">
|
|
211
|
+
<a href="#M000168" class="method-signature">
|
|
212
|
+
<span class="method-name">process</span><span class="method-args">(input, context=nil, filename=nil)</span>
|
|
401
213
|
</a>
|
|
402
214
|
</div>
|
|
403
215
|
|
|
404
216
|
<div class="method-description">
|
|
405
217
|
<p>
|
|
406
|
-
|
|
218
|
+
helper method to convert and evaluate input text with context object.
|
|
219
|
+
context may be Binding, Hash, or Object.
|
|
407
220
|
</p>
|
|
408
221
|
<p><a class="source-toggle" href="#"
|
|
409
|
-
onclick="toggleCode('
|
|
410
|
-
<div class="method-source-code" id="
|
|
222
|
+
onclick="toggleCode('M000168-source');return false;">[Source]</a></p>
|
|
223
|
+
<div class="method-source-code" id="M000168-source">
|
|
411
224
|
<pre>
|
|
412
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line
|
|
413
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
|
414
|
-
<span class="ruby-
|
|
415
|
-
<span class="ruby-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
<span class="ruby-identifier">
|
|
225
|
+
<span class="ruby-comment cmt"># File erubis/engine.rb, line 53</span>
|
|
226
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">context</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>)
|
|
227
|
+
<span class="ruby-identifier">code</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>)
|
|
228
|
+
<span class="ruby-identifier">filename</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'(erubis)'</span>
|
|
229
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Binding</span>)
|
|
230
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">filename</span>)
|
|
231
|
+
<span class="ruby-keyword kw">else</span>
|
|
232
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>) <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>)
|
|
233
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">filename</span>)
|
|
421
234
|
<span class="ruby-keyword kw">end</span>
|
|
422
235
|
<span class="ruby-keyword kw">end</span>
|
|
423
236
|
</pre>
|
|
@@ -425,285 +238,32 @@ add expression code to src
|
|
|
425
238
|
</div>
|
|
426
239
|
</div>
|
|
427
240
|
|
|
428
|
-
<div id="method-
|
|
429
|
-
<a name="
|
|
430
|
-
|
|
431
|
-
<div class="method-heading">
|
|
432
|
-
<a href="#M000078" class="method-signature">
|
|
433
|
-
<span class="method-name">add_expr_debug</span><span class="method-args">(src, code)</span>
|
|
434
|
-
</a>
|
|
435
|
-
</div>
|
|
436
|
-
|
|
437
|
-
<div class="method-description">
|
|
438
|
-
<p>
|
|
439
|
-
.[abstract] add expression code to src for debug. this is called by <a
|
|
440
|
-
href="Engine.html#M000075">add_expr</a>().
|
|
441
|
-
</p>
|
|
442
|
-
<p><a class="source-toggle" href="#"
|
|
443
|
-
onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
|
|
444
|
-
<div class="method-source-code" id="M000078-source">
|
|
445
|
-
<pre>
|
|
446
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 259</span>
|
|
447
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr_debug</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
|
|
448
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
449
|
-
<span class="ruby-keyword kw">end</span>
|
|
450
|
-
</pre>
|
|
451
|
-
</div>
|
|
452
|
-
</div>
|
|
453
|
-
</div>
|
|
454
|
-
|
|
455
|
-
<div id="method-M000077" class="method-detail">
|
|
456
|
-
<a name="M000077"></a>
|
|
457
|
-
|
|
458
|
-
<div class="method-heading">
|
|
459
|
-
<a href="#M000077" class="method-signature">
|
|
460
|
-
<span class="method-name">add_expr_escaped</span><span class="method-args">(src, code)</span>
|
|
461
|
-
</a>
|
|
462
|
-
</div>
|
|
463
|
-
|
|
464
|
-
<div class="method-description">
|
|
465
|
-
<p>
|
|
466
|
-
.[abstract] add escaped expression code to src. this is called by <a
|
|
467
|
-
href="Engine.html#M000075">add_expr</a>().
|
|
468
|
-
</p>
|
|
469
|
-
<p><a class="source-toggle" href="#"
|
|
470
|
-
onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
|
|
471
|
-
<div class="method-source-code" id="M000077-source">
|
|
472
|
-
<pre>
|
|
473
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 254</span>
|
|
474
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr_escaped</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
|
|
475
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
476
|
-
<span class="ruby-keyword kw">end</span>
|
|
477
|
-
</pre>
|
|
478
|
-
</div>
|
|
479
|
-
</div>
|
|
480
|
-
</div>
|
|
481
|
-
|
|
482
|
-
<div id="method-M000076" class="method-detail">
|
|
483
|
-
<a name="M000076"></a>
|
|
484
|
-
|
|
485
|
-
<div class="method-heading">
|
|
486
|
-
<a href="#M000076" class="method-signature">
|
|
487
|
-
<span class="method-name">add_expr_literal</span><span class="method-args">(src, code)</span>
|
|
488
|
-
</a>
|
|
489
|
-
</div>
|
|
490
|
-
|
|
491
|
-
<div class="method-description">
|
|
492
|
-
<p>
|
|
493
|
-
.[abstract] add expression literal code to src. this is called by <a
|
|
494
|
-
href="Engine.html#M000075">add_expr</a>().
|
|
495
|
-
</p>
|
|
496
|
-
<p><a class="source-toggle" href="#"
|
|
497
|
-
onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
|
|
498
|
-
<div class="method-source-code" id="M000076-source">
|
|
499
|
-
<pre>
|
|
500
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 249</span>
|
|
501
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr_literal</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
|
|
502
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
503
|
-
<span class="ruby-keyword kw">end</span>
|
|
504
|
-
</pre>
|
|
505
|
-
</div>
|
|
506
|
-
</div>
|
|
507
|
-
</div>
|
|
508
|
-
|
|
509
|
-
<div id="method-M000079" class="method-detail">
|
|
510
|
-
<a name="M000079"></a>
|
|
511
|
-
|
|
512
|
-
<div class="method-heading">
|
|
513
|
-
<a href="#M000079" class="method-signature">
|
|
514
|
-
<span class="method-name">add_postamble</span><span class="method-args">(src)</span>
|
|
515
|
-
</a>
|
|
516
|
-
</div>
|
|
517
|
-
|
|
518
|
-
<div class="method-description">
|
|
519
|
-
<p>
|
|
520
|
-
.[abstract] add @postamble to src
|
|
521
|
-
</p>
|
|
522
|
-
<p><a class="source-toggle" href="#"
|
|
523
|
-
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
|
524
|
-
<div class="method-source-code" id="M000079-source">
|
|
525
|
-
<pre>
|
|
526
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 264</span>
|
|
527
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_postamble</span>(<span class="ruby-identifier">src</span>)
|
|
528
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
529
|
-
<span class="ruby-keyword kw">end</span>
|
|
530
|
-
</pre>
|
|
531
|
-
</div>
|
|
532
|
-
</div>
|
|
533
|
-
</div>
|
|
534
|
-
|
|
535
|
-
<div id="method-M000072" class="method-detail">
|
|
536
|
-
<a name="M000072"></a>
|
|
537
|
-
|
|
538
|
-
<div class="method-heading">
|
|
539
|
-
<a href="#M000072" class="method-signature">
|
|
540
|
-
<span class="method-name">add_preamble</span><span class="method-args">(src)</span>
|
|
541
|
-
</a>
|
|
542
|
-
</div>
|
|
543
|
-
|
|
544
|
-
<div class="method-description">
|
|
545
|
-
<p>
|
|
546
|
-
.[abstract] add @preamble to src
|
|
547
|
-
</p>
|
|
548
|
-
<p><a class="source-toggle" href="#"
|
|
549
|
-
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
|
|
550
|
-
<div class="method-source-code" id="M000072-source">
|
|
551
|
-
<pre>
|
|
552
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 222</span>
|
|
553
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_preamble</span>(<span class="ruby-identifier">src</span>)
|
|
554
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
555
|
-
<span class="ruby-keyword kw">end</span>
|
|
556
|
-
</pre>
|
|
557
|
-
</div>
|
|
558
|
-
</div>
|
|
559
|
-
</div>
|
|
560
|
-
|
|
561
|
-
<div id="method-M000074" class="method-detail">
|
|
562
|
-
<a name="M000074"></a>
|
|
563
|
-
|
|
564
|
-
<div class="method-heading">
|
|
565
|
-
<a href="#M000074" class="method-signature">
|
|
566
|
-
<span class="method-name">add_stmt</span><span class="method-args">(src, code)</span>
|
|
567
|
-
</a>
|
|
568
|
-
</div>
|
|
569
|
-
|
|
570
|
-
<div class="method-description">
|
|
571
|
-
<p>
|
|
572
|
-
.[abstract] add statement code to src
|
|
573
|
-
</p>
|
|
574
|
-
<p><a class="source-toggle" href="#"
|
|
575
|
-
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
|
576
|
-
<div class="method-source-code" id="M000074-source">
|
|
577
|
-
<pre>
|
|
578
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 232</span>
|
|
579
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
|
|
580
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
581
|
-
<span class="ruby-keyword kw">end</span>
|
|
582
|
-
</pre>
|
|
583
|
-
</div>
|
|
584
|
-
</div>
|
|
585
|
-
</div>
|
|
586
|
-
|
|
587
|
-
<div id="method-M000073" class="method-detail">
|
|
588
|
-
<a name="M000073"></a>
|
|
589
|
-
|
|
590
|
-
<div class="method-heading">
|
|
591
|
-
<a href="#M000073" class="method-signature">
|
|
592
|
-
<span class="method-name">add_text</span><span class="method-args">(src, text)</span>
|
|
593
|
-
</a>
|
|
594
|
-
</div>
|
|
595
|
-
|
|
596
|
-
<div class="method-description">
|
|
597
|
-
<p>
|
|
598
|
-
.[abstract] add text string to src
|
|
599
|
-
</p>
|
|
600
|
-
<p><a class="source-toggle" href="#"
|
|
601
|
-
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
|
|
602
|
-
<div class="method-source-code" id="M000073-source">
|
|
603
|
-
<pre>
|
|
604
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 227</span>
|
|
605
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">text</span>)
|
|
606
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
607
|
-
<span class="ruby-keyword kw">end</span>
|
|
608
|
-
</pre>
|
|
609
|
-
</div>
|
|
610
|
-
</div>
|
|
611
|
-
</div>
|
|
612
|
-
|
|
613
|
-
<div id="method-M000070" class="method-detail">
|
|
614
|
-
<a name="M000070"></a>
|
|
615
|
-
|
|
616
|
-
<div class="method-heading">
|
|
617
|
-
<a href="#M000070" class="method-signature">
|
|
618
|
-
<span class="method-name">escape_text</span><span class="method-args">(text)</span>
|
|
619
|
-
</a>
|
|
620
|
-
</div>
|
|
621
|
-
|
|
622
|
-
<div class="method-description">
|
|
623
|
-
<p>
|
|
624
|
-
.[abstract] escape text string
|
|
625
|
-
</p>
|
|
626
|
-
<p>
|
|
627
|
-
ex.
|
|
628
|
-
</p>
|
|
629
|
-
<pre>
|
|
630
|
-
def escape_text(text)
|
|
631
|
-
return text.dump
|
|
632
|
-
# or return "'" + text.gsub(/['\\]/, '\\\\\&') + "'"
|
|
633
|
-
end
|
|
634
|
-
</pre>
|
|
635
|
-
<p><a class="source-toggle" href="#"
|
|
636
|
-
onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
|
|
637
|
-
<div class="method-source-code" id="M000070-source">
|
|
638
|
-
<pre>
|
|
639
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 206</span>
|
|
640
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_text</span>(<span class="ruby-identifier">text</span>)
|
|
641
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
642
|
-
<span class="ruby-keyword kw">end</span>
|
|
643
|
-
</pre>
|
|
644
|
-
</div>
|
|
645
|
-
</div>
|
|
646
|
-
</div>
|
|
647
|
-
|
|
648
|
-
<div id="method-M000071" class="method-detail">
|
|
649
|
-
<a name="M000071"></a>
|
|
650
|
-
|
|
651
|
-
<div class="method-heading">
|
|
652
|
-
<a href="#M000071" class="method-signature">
|
|
653
|
-
<span class="method-name">escaped_expr</span><span class="method-args">(code)</span>
|
|
654
|
-
</a>
|
|
655
|
-
</div>
|
|
656
|
-
|
|
657
|
-
<div class="method-description">
|
|
658
|
-
<p>
|
|
659
|
-
.[abstract] return escaped expression code
|
|
660
|
-
</p>
|
|
661
|
-
<p>
|
|
662
|
-
ex.
|
|
663
|
-
</p>
|
|
664
|
-
<pre>
|
|
665
|
-
def escaped_expr(code)
|
|
666
|
-
@escape ||= 'escape'
|
|
667
|
-
return "#{@escape}(#{code.strip})"
|
|
668
|
-
end
|
|
669
|
-
</pre>
|
|
670
|
-
<p><a class="source-toggle" href="#"
|
|
671
|
-
onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
|
|
672
|
-
<div class="method-source-code" id="M000071-source">
|
|
673
|
-
<pre>
|
|
674
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line 217</span>
|
|
675
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escaped_expr</span>(<span class="ruby-identifier">code</span>)
|
|
676
|
-
<span class="ruby-identifier">not_implemented</span>
|
|
677
|
-
<span class="ruby-keyword kw">end</span>
|
|
678
|
-
</pre>
|
|
679
|
-
</div>
|
|
680
|
-
</div>
|
|
681
|
-
</div>
|
|
682
|
-
|
|
683
|
-
<div id="method-M000067" class="method-detail">
|
|
684
|
-
<a name="M000067"></a>
|
|
241
|
+
<div id="method-M000169" class="method-detail">
|
|
242
|
+
<a name="M000169"></a>
|
|
685
243
|
|
|
686
244
|
<div class="method-heading">
|
|
687
|
-
<a href="#
|
|
688
|
-
<span class="method-name">
|
|
245
|
+
<a href="#M000169" class="method-signature">
|
|
246
|
+
<span class="method-name">process_proc</span><span class="method-args">(proc_obj, context=nil, filename=nil)</span>
|
|
689
247
|
</a>
|
|
690
248
|
</div>
|
|
691
249
|
|
|
692
250
|
<div class="method-description">
|
|
693
251
|
<p>
|
|
694
|
-
|
|
252
|
+
helper method evaluate Proc object iwth contect object. context may be
|
|
253
|
+
Binding, Hash, or Object.
|
|
695
254
|
</p>
|
|
696
255
|
<p><a class="source-toggle" href="#"
|
|
697
|
-
onclick="toggleCode('
|
|
698
|
-
<div class="method-source-code" id="
|
|
256
|
+
onclick="toggleCode('M000169-source');return false;">[Source]</a></p>
|
|
257
|
+
<div class="method-source-code" id="M000169-source">
|
|
699
258
|
<pre>
|
|
700
|
-
<span class="ruby-comment cmt"># File erubis/engine.rb, line
|
|
701
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
|
702
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">
|
|
703
|
-
<span class="ruby-
|
|
259
|
+
<span class="ruby-comment cmt"># File erubis/engine.rb, line 69</span>
|
|
260
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_proc</span>(<span class="ruby-identifier">proc_obj</span>, <span class="ruby-identifier">context</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>)
|
|
261
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Binding</span>)
|
|
262
|
+
<span class="ruby-identifier">filename</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'(erubis)'</span>
|
|
263
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">proc_obj</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">filename</span>)
|
|
704
264
|
<span class="ruby-keyword kw">else</span>
|
|
705
|
-
<span class="ruby-identifier">
|
|
706
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-
|
|
265
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>) <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>)
|
|
266
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">proc_obj</span>)
|
|
707
267
|
<span class="ruby-keyword kw">end</span>
|
|
708
268
|
<span class="ruby-keyword kw">end</span>
|
|
709
269
|
</pre>
|