erubis 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/ChangeLog +150 -2
  2. data/LGPL +504 -0
  3. data/README.txt +14 -8
  4. data/benchmark/erubybench.rb +1 -1
  5. data/benchmark/erubybench.rhtml +3 -3
  6. data/bin/erubis +1 -1
  7. data/bin/notext +154 -0
  8. data/contrib/erubis +1036 -374
  9. data/contrib/inline-require +5 -3
  10. data/doc-api/classes/Erubis.html +43 -1
  11. data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +14 -14
  12. data/doc-api/classes/Erubis/ArrayEnhancer.html +14 -14
  13. data/doc-api/classes/Erubis/Basic.html +112 -0
  14. data/doc-api/classes/Erubis/Basic/Converter.html +318 -0
  15. data/doc-api/classes/Erubis/Basic/Engine.html +130 -0
  16. data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
  17. data/doc-api/classes/Erubis/CGenerator.html +386 -0
  18. data/doc-api/classes/Erubis/Context.html +31 -32
  19. data/doc-api/classes/Erubis/Converter.html +231 -0
  20. data/doc-api/classes/Erubis/Ec.html +9 -283
  21. data/doc-api/classes/Erubis/Ejava.html +9 -274
  22. data/doc-api/classes/Erubis/Ejavascript.html +9 -298
  23. data/doc-api/classes/Erubis/Engine.html +68 -508
  24. data/doc-api/classes/Erubis/Eperl.html +9 -259
  25. data/doc-api/classes/Erubis/Ephp.html +9 -239
  26. data/doc-api/classes/Erubis/ErubisError.html +2 -2
  27. data/doc-api/classes/Erubis/Eruby.html +4 -187
  28. data/doc-api/classes/Erubis/EscapeEnhancer.html +9 -11
  29. data/doc-api/classes/Erubis/Escheme.html +9 -272
  30. data/doc-api/classes/Erubis/Evaluator.html +212 -0
  31. data/doc-api/classes/Erubis/Generator.html +410 -0
  32. data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +16 -16
  33. data/doc-api/classes/Erubis/Helper.html +112 -0
  34. data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +198 -0
  35. data/doc-api/classes/Erubis/Helper/RailsTemplate.html +366 -0
  36. data/doc-api/classes/Erubis/JavaGenerator.html +359 -0
  37. data/doc-api/classes/Erubis/JavascriptGenerator.html +381 -0
  38. data/doc-api/classes/Erubis/Main.html +27 -25
  39. data/doc-api/classes/Erubis/NoCodeEnhancer.html +249 -0
  40. data/doc-api/classes/Erubis/NoCodeEruby.html +120 -0
  41. data/doc-api/classes/Erubis/NoTextEnhancer.html +8 -8
  42. data/doc-api/classes/Erubis/NotSupportedError.html +119 -0
  43. data/doc-api/classes/Erubis/OptimizedEruby.html +22 -304
  44. data/doc-api/classes/Erubis/OptimizedGenerator.html +439 -0
  45. data/doc-api/classes/Erubis/OptimizedXmlEruby.html +7 -7
  46. data/doc-api/classes/Erubis/PI.html +124 -0
  47. data/doc-api/classes/Erubis/PI/Converter.html +318 -0
  48. data/doc-api/classes/Erubis/PI/Ec.html +166 -0
  49. data/doc-api/classes/Erubis/PI/Ejava.html +166 -0
  50. data/doc-api/classes/Erubis/PI/Ejavascript.html +166 -0
  51. data/doc-api/classes/Erubis/PI/Engine.html +122 -0
  52. data/doc-api/classes/Erubis/PI/Eperl.html +166 -0
  53. data/doc-api/classes/Erubis/PI/Ephp.html +166 -0
  54. data/doc-api/classes/Erubis/PI/Eruby.html +155 -0
  55. data/doc-api/classes/Erubis/PI/Escheme.html +166 -0
  56. data/doc-api/classes/Erubis/PI/TinyEruby.html +305 -0
  57. data/doc-api/classes/Erubis/PercentLineEnhancer.html +7 -7
  58. data/doc-api/classes/Erubis/PerlGenerator.html +344 -0
  59. data/doc-api/classes/Erubis/PhpGenerator.html +350 -0
  60. data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +24 -24
  61. data/doc-api/classes/Erubis/PrintOutEnhancer.html +35 -35
  62. data/doc-api/classes/Erubis/RubyEvaluator.html +190 -0
  63. data/doc-api/classes/Erubis/RubyGenerator.html +327 -0
  64. data/doc-api/classes/Erubis/SchemeGenerator.html +382 -0
  65. data/doc-api/classes/Erubis/SimplifyEnhancer.html +17 -13
  66. data/doc-api/classes/Erubis/StdoutEnhancer.html +14 -14
  67. data/doc-api/classes/Erubis/StringBufferEnhancer.html +14 -14
  68. data/doc-api/classes/Erubis/TinyEruby.html +45 -40
  69. data/doc-api/classes/Erubis/XmlHelper.html +14 -14
  70. data/doc-api/created.rid +1 -1
  71. data/doc-api/files/__/README_txt.html +27 -9
  72. data/doc-api/files/erubis/context_rb.html +107 -0
  73. data/doc-api/files/erubis/converter_rb.html +114 -0
  74. data/doc-api/files/erubis/engine/ec_rb.html +2 -2
  75. data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
  76. data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
  77. data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
  78. data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
  79. data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
  80. data/doc-api/files/erubis/engine/eruby_rb.html +3 -2
  81. data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
  82. data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
  83. data/doc-api/files/erubis/engine_rb.html +6 -3
  84. data/doc-api/files/erubis/enhancer_rb.html +2 -9
  85. data/doc-api/files/erubis/error_rb.html +107 -0
  86. data/doc-api/files/erubis/evaluator_rb.html +115 -0
  87. data/doc-api/files/erubis/generator_rb.html +114 -0
  88. data/doc-api/files/erubis/helper/rails_rb.html +140 -0
  89. data/doc-api/files/erubis/helper_rb.html +1 -1
  90. data/doc-api/files/erubis/local-setting_rb.html +1 -1
  91. data/doc-api/files/erubis/main_rb.html +2 -2
  92. data/doc-api/files/erubis/tiny_rb.html +2 -2
  93. data/doc-api/files/erubis_rb.html +2 -2
  94. data/doc-api/fr_class_index.html +32 -0
  95. data/doc-api/fr_file_index.html +6 -0
  96. data/doc-api/fr_method_index.html +178 -136
  97. data/doc/users-guide.html +538 -199
  98. data/examples/{Makefile → basic/Makefile} +11 -11
  99. data/examples/basic/example.ec +42 -0
  100. data/examples/{example.ejava → basic/example.ejava} +5 -1
  101. data/examples/{example.ejavascript → basic/example.ejs} +0 -0
  102. data/examples/{example.eperl → basic/example.eperl} +2 -2
  103. data/examples/{example.ephp → basic/example.ephp} +0 -0
  104. data/examples/{example.eruby → basic/example.eruby} +0 -0
  105. data/examples/{example.escheme → basic/example.escheme} +0 -0
  106. data/examples/pi/Makefile +54 -0
  107. data/examples/pi/example.ec +42 -0
  108. data/examples/pi/example.ejava +45 -0
  109. data/examples/pi/example.ejs +16 -0
  110. data/examples/pi/example.eperl +16 -0
  111. data/examples/pi/example.ephp +17 -0
  112. data/examples/pi/example.eruby +15 -0
  113. data/examples/pi/example.escheme +26 -0
  114. data/lib/erubis.rb +15 -8
  115. data/lib/erubis/context.rb +54 -0
  116. data/lib/erubis/converter.rb +307 -0
  117. data/lib/erubis/engine.rb +57 -227
  118. data/lib/erubis/engine/ec.rb +31 -20
  119. data/lib/erubis/engine/ejava.rb +33 -21
  120. data/lib/erubis/engine/ejavascript.rb +30 -18
  121. data/lib/erubis/engine/enhanced.rb +7 -2
  122. data/lib/erubis/engine/eperl.rb +33 -19
  123. data/lib/erubis/engine/ephp.rb +32 -14
  124. data/lib/erubis/engine/eruby.rb +34 -7
  125. data/lib/erubis/engine/escheme.rb +34 -15
  126. data/lib/erubis/engine/optimized.rb +25 -11
  127. data/lib/erubis/enhancer.rb +53 -19
  128. data/lib/erubis/error.rb +24 -0
  129. data/lib/erubis/evaluator.rb +71 -0
  130. data/lib/erubis/generator.rb +83 -0
  131. data/lib/erubis/helper.rb +1 -1
  132. data/lib/erubis/helper/rails.rb +159 -0
  133. data/lib/erubis/local-setting.rb +1 -1
  134. data/lib/erubis/main.rb +87 -46
  135. data/lib/erubis/tiny.rb +81 -7
  136. data/test/assert-text-equal.rb +1 -1
  137. data/test/test-engines.rb +8 -9
  138. data/test/test-erubis.rb +196 -18
  139. data/test/{test-bin.rb → test-main.rb} +123 -21
  140. data/test/test-notext.rb +27 -0
  141. data/test/test.rb +5 -3
  142. data/test/testutil.rb +25 -36
  143. metadata +75 -13
  144. data/COPYING +0 -340
  145. data/examples/example.ec +0 -24
@@ -80,7 +80,8 @@
80
80
 
81
81
  <div id="description">
82
82
  <p>
83
- .[abstract] base engine class
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="#M000075">add_expr</a>&nbsp;&nbsp;
96
- <a href="#M000078">add_expr_debug</a>&nbsp;&nbsp;
97
- <a href="#M000077">add_expr_escaped</a>&nbsp;&nbsp;
98
- <a href="#M000076">add_expr_literal</a>&nbsp;&nbsp;
99
- <a href="#M000079">add_postamble</a>&nbsp;&nbsp;
100
- <a href="#M000072">add_preamble</a>&nbsp;&nbsp;
101
- <a href="#M000074">add_stmt</a>&nbsp;&nbsp;
102
- <a href="#M000073">add_text</a>&nbsp;&nbsp;
103
- <a href="#M000068">compile</a>&nbsp;&nbsp;
104
- <a href="#M000069">compile!</a>&nbsp;&nbsp;
105
- <a href="#M000070">escape_text</a>&nbsp;&nbsp;
106
- <a href="#M000071">escaped_expr</a>&nbsp;&nbsp;
107
- <a href="#M000066">evaluate</a>&nbsp;&nbsp;
108
- <a href="#M000064">load_file</a>&nbsp;&nbsp;
109
- <a href="#M000063">new</a>&nbsp;&nbsp;
110
- <a href="#M000067">pattern_regexp</a>&nbsp;&nbsp;
111
- <a href="#M000065">result</a>&nbsp;&nbsp;
96
+ <a href="#M000165">convert!</a>&nbsp;&nbsp;
97
+ <a href="#M000167">load_file</a>&nbsp;&nbsp;
98
+ <a href="#M000166">new</a>&nbsp;&nbsp;
99
+ <a href="#M000168">process</a>&nbsp;&nbsp;
100
+ <a href="#M000169">process_proc</a>&nbsp;&nbsp;
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]*)?&lt;%(=+|\#)?(.*?)-?%&gt;([ \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">&nbsp;[RW]&nbsp;</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">&nbsp;[R]&nbsp;</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-M000064" class="method-detail">
165
- <a name="M000064"></a>
122
+ <div id="method-M000167" class="method-detail">
123
+ <a name="M000167"></a>
166
124
 
167
125
  <div class="method-heading">
168
- <a href="#M000064" class="method-signature">
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('M000064-source');return false;">[Source]</a></p>
179
- <div class="method-source-code" id="M000064-source">
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 93</span>
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-M000063" class="method-detail">
195
- <a name="M000063"></a>
152
+ <div id="method-M000166" class="method-detail">
153
+ <a name="M000166"></a>
196
154
 
197
155
  <div class="method-heading">
198
- <a href="#M000063" class="method-signature">
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('M000063-source');return false;">[Source]</a></p>
206
- <div class="method-source-code" id="M000063-source">
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 79</span>
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 = input</span>
211
- <span class="ruby-ivar">@pattern</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:pattern</span>]
212
- <span class="ruby-ivar">@filename</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:filename</span>]
213
- <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>
214
- <span class="ruby-ivar">@preamble</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:preamble</span>]
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-M000068" class="method-detail">
227
- <a name="M000068"></a>
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">&quot;&quot;</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">&amp;&amp;</span> (<span class="ruby-identifier">src</span> <span class="ruby-operator">&lt;&lt;</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 '&lt;%= %&gt;', do nothing</span>
251
- <span class="ruby-comment cmt">## * when '&lt;% %&gt;' or '&lt;%# %&gt;', delete spaces iff only spaces are around '&lt;% %&gt;'</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"># &lt;% %&gt;</span>
253
- <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@trim</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">lspace</span> <span class="ruby-operator">&amp;&amp;</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">&quot;#{lspace}#{code}#{rspace}&quot;</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"># &lt;%# %&gt;</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">&quot;\n&quot;</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">&amp;&amp;</span> <span class="ruby-identifier">lspace</span> <span class="ruby-operator">&amp;&amp;</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">&quot;\n&quot;</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">&quot;\n&quot;</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 &amp;&amp; lspace &amp;&amp; rspace</span>
270
- <span class="ruby-comment cmt">#add_text(src, lspace) if !flag_trim &amp;&amp; lspace</span>
271
- <span class="ruby-comment cmt">#n = code.count(&quot;\n&quot;) + (rspace ? 1 : 0)</span>
272
- <span class="ruby-comment cmt">#add_stmt(src, &quot;\n&quot; * n)</span>
273
- <span class="ruby-comment cmt">#add_text(src, rspace) if !flag_trim &amp;&amp; rspace</span>
274
- <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># &lt;%= %&gt;</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 &amp;&amp; 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 &amp;&amp; lspace &amp;&amp; rspace</span>
283
- <span class="ruby-comment cmt">#end</span>
284
- <span class="ruby-comment cmt">##flag_trim = @trim &amp;&amp; !(indicator &amp;&amp; indicator[0]==?=) &amp;&amp; lspace &amp;&amp; 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 &amp;&amp; lspace</span>
287
- <span class="ruby-comment cmt">#if !indicator # &lt;% %&gt;</span>
288
- <span class="ruby-comment cmt"># code = &quot;#{lspace}#{code}#{rspace}&quot; if flag_trim</span>
289
- <span class="ruby-comment cmt"># add_stmt(src, code)</span>
290
- <span class="ruby-comment cmt">#elsif indicator[0] == ?\# # &lt;%# %&gt;</span>
291
- <span class="ruby-comment cmt"># n = code.count(&quot;\n&quot;) + (rspace ? 1 : 0)</span>
292
- <span class="ruby-comment cmt"># add_stmt(src, &quot;\n&quot; * n)</span>
293
- <span class="ruby-comment cmt">#else # &lt;%= %&gt;</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 &amp;&amp; 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">&amp;&amp;</span> (<span class="ruby-identifier">src</span> <span class="ruby-operator">&lt;&lt;</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="#M000065" class="method-signature">
366
- <span class="method-name">result</span><span class="method-args">(_binding_or_hash=TOPLEVEL_BINDING)</span>
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
- eval(@src) with binding object
192
+ convert input string and set it to @src
373
193
  </p>
374
194
  <p><a class="source-toggle" href="#"
375
- onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
376
- <div class="method-source-code" id="M000065-source">
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 102</span>
379
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">result</span>(<span class="ruby-identifier">_binding_or_hash</span>=<span class="ruby-constant">TOPLEVEL_BINDING</span>)
380
- <span class="ruby-identifier">_arg</span> = <span class="ruby-identifier">_binding_or_hash</span>
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">&quot;&quot;</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">&lt;&lt;</span> <span class="ruby-node">&quot;#{k.to_s} = _arg[#{k.inspect}];&quot;</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
- <h3 class="section-bar">Protected Instance methods</h3>
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="#M000075" class="method-signature">
400
- <span class="method-name">add_expr</span><span class="method-args">(src, code, indicator)</span>
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
- add expression code to src
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('M000075-source');return false;">[Source]</a></p>
410
- <div class="method-source-code" id="M000075-source">
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 237</span>
413
- <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>)
414
- <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">indicator</span>
415
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'='</span>
416
- <span class="ruby-identifier">add_expr_literal</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
417
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'=='</span>
418
- <span class="ruby-identifier">add_expr_escaped</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
419
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'==='</span>
420
- <span class="ruby-identifier">add_expr_debug</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">code</span>)
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-M000078" class="method-detail">
429
- <a name="M000078"></a>
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 &quot;'&quot; + text.gsub(/['\\]/, '\\\\\&amp;') + &quot;'&quot;
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 &quot;#{@escape}(#{code.strip})&quot;
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="#M000067" class="method-signature">
688
- <span class="method-name">pattern_regexp</span><span class="method-args">(pattern=@pattern)</span>
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
- return regexp of pattern to parse eRuby script
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('M000067-source');return false;">[Source]</a></p>
698
- <div class="method-source-code" id="M000067-source">
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 121</span>
701
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pattern_regexp</span>(<span class="ruby-identifier">pattern</span>=<span class="ruby-ivar">@pattern</span>)
702
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">pattern</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'&lt;% %&gt;'</span>
703
- <span class="ruby-keyword kw">return</span> <span class="ruby-constant">DEFAULT_REGEXP</span>
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">prefix</span>, <span class="ruby-identifier">postfix</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">split</span>()
706
- <span class="ruby-keyword kw">return</span> <span class="ruby-node">/(.*?)(^[ \t]*)?#{prefix}(=+|\#)?(.*?)-?#{postfix}([ \t]*\r?\n)?/</span><span class="ruby-identifier">m</span>
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">&amp;</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>