erubis 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{ChangeLog → CHANGES} +139 -6
- data/MIT-LICENSE +20 -0
- data/README.txt +20 -5
- data/benchmark/erubybench.rb +465 -229
- data/benchmark/erubybench.rhtml +39 -15
- data/benchmark/erubybench.yaml +126 -46
- data/bin/erubis +2 -2
- data/bin/notext +3 -3
- data/contrib/action_view_base_rb.patch +23 -0
- data/contrib/erubis +466 -308
- data/contrib/inline-require +2 -2
- data/doc-api/classes/ERB.html +101 -0
- data/doc-api/classes/Erubis.html +59 -6
- data/doc-api/classes/Erubis/ArrayEnhancer.html +12 -12
- data/doc-api/classes/Erubis/Basic/Converter.html +61 -57
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
- data/doc-api/classes/Erubis/CGenerator.html +60 -60
- data/doc-api/classes/Erubis/Context.html +125 -29
- data/doc-api/classes/Erubis/Converter.html +73 -22
- data/doc-api/classes/Erubis/Engine.html +55 -39
- data/doc-api/classes/Erubis/EscapeEnhancer.html +6 -6
- data/doc-api/classes/Erubis/Evaluator.html +19 -19
- data/doc-api/classes/Erubis/Generator.html +16 -10
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +14 -14
- data/doc-api/classes/Erubis/{Helper.html → Helpers.html} +5 -6
- data/doc-api/classes/Erubis/Helpers/RailsHelper.html +296 -0
- data/doc-api/classes/Erubis/JavaGenerator.html +54 -54
- data/doc-api/classes/Erubis/JavascriptGenerator.html +60 -60
- data/doc-api/classes/Erubis/Main.html +42 -30
- data/doc-api/classes/Erubis/NoCodeEnhancer.html +5 -5
- data/doc-api/classes/Erubis/NoTextEnhancer.html +7 -7
- data/doc-api/classes/Erubis/OptimizedEruby.html +6 -6
- data/doc-api/classes/Erubis/OptimizedGenerator.html +72 -72
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +6 -6
- data/doc-api/classes/Erubis/PI/Converter.html +28 -81
- data/doc-api/classes/Erubis/PI/Ec.html +6 -6
- data/doc-api/classes/Erubis/PI/Ejava.html +6 -6
- data/doc-api/classes/Erubis/PI/Ejavascript.html +6 -6
- data/doc-api/classes/Erubis/PI/Eperl.html +6 -6
- data/doc-api/classes/Erubis/PI/Ephp.html +6 -6
- data/doc-api/classes/Erubis/PI/Eruby.html +7 -7
- data/doc-api/classes/Erubis/PI/Escheme.html +6 -6
- data/doc-api/classes/Erubis/PI/TinyEruby.html +66 -79
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +8 -8
- data/doc-api/classes/Erubis/PerlGenerator.html +54 -54
- data/doc-api/classes/Erubis/PhpGenerator.html +54 -54
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +21 -21
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +30 -30
- data/doc-api/classes/Erubis/RubyEvaluator.html +12 -12
- data/doc-api/classes/Erubis/RubyGenerator.html +9 -9
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +7 -6
- data/doc-api/classes/Erubis/StdoutEnhancer.html +12 -12
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +13 -13
- data/doc-api/classes/Erubis/TinyEruby.html +56 -68
- data/doc-api/classes/Erubis/XmlHelper.html +20 -23
- data/doc-api/created.rid +1 -1
- data/doc-api/files/{__/README_txt.html → README_txt.html} +35 -20
- data/doc-api/files/erubis/context_rb.html +2 -2
- data/doc-api/files/erubis/converter_rb.html +2 -2
- data/doc-api/files/erubis/engine/ec_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
- data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
- data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
- data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
- data/doc-api/files/erubis/engine/eruby_rb.html +2 -3
- data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
- data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
- data/doc-api/files/erubis/engine_rb.html +2 -2
- data/doc-api/files/erubis/enhancer_rb.html +2 -2
- data/doc-api/files/erubis/error_rb.html +2 -2
- data/doc-api/files/erubis/evaluator_rb.html +2 -2
- data/doc-api/files/erubis/generator_rb.html +2 -2
- data/doc-api/files/erubis/helper_rb.html +2 -2
- data/doc-api/files/erubis/{helper/rails_rb.html → helpers/rails_helper_rb.html} +6 -31
- data/doc-api/files/erubis/local-setting_rb.html +2 -2
- data/doc-api/files/erubis/main_rb.html +4 -2
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +3 -3
- data/doc-api/fr_file_index.html +2 -2
- data/doc-api/fr_method_index.html +142 -147
- data/doc-api/index.html +1 -1
- data/doc/users-guide.html +387 -218
- data/lib/erubis.rb +21 -25
- data/lib/erubis/context.rb +34 -4
- data/lib/erubis/converter.rb +159 -115
- data/lib/erubis/engine.rb +29 -12
- data/lib/erubis/engine/ec.rb +2 -2
- data/lib/erubis/engine/ejava.rb +2 -2
- data/lib/erubis/engine/ejavascript.rb +2 -2
- data/lib/erubis/engine/enhanced.rb +2 -2
- data/lib/erubis/engine/eperl.rb +2 -2
- data/lib/erubis/engine/ephp.rb +2 -2
- data/lib/erubis/engine/eruby.rb +5 -6
- data/lib/erubis/engine/escheme.rb +2 -2
- data/lib/erubis/engine/optimized.rb +2 -2
- data/lib/erubis/enhancer.rb +33 -7
- data/lib/erubis/error.rb +2 -2
- data/lib/erubis/evaluator.rb +2 -2
- data/lib/erubis/generator.rb +6 -3
- data/lib/erubis/helper.rb +6 -23
- data/lib/erubis/helpers/rails_helper.rb +202 -0
- data/lib/erubis/local-setting.rb +4 -4
- data/lib/erubis/main.rb +90 -35
- data/lib/erubis/tiny.rb +57 -52
- data/test/assert-text-equal.rb +2 -2
- data/test/test-engines.rb +5 -5
- data/test/test-erubis.rb +173 -63
- data/test/test-main.rb +135 -27
- data/test/test-notext.rb +2 -2
- data/test/test.rb +2 -2
- data/test/testutil.rb +2 -2
- metadata +16 -16
- data/LGPL +0 -504
- data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +0 -198
- data/doc-api/classes/Erubis/Helper/RailsTemplate.html +0 -366
- data/lib/erubis/helper/rails.rb +0 -159
|
@@ -89,8 +89,8 @@ this is only for <a href="Eruby.html">Eruby</a>.
|
|
|
89
89
|
<h3 class="section-bar">Methods</h3>
|
|
90
90
|
|
|
91
91
|
<div class="name-list">
|
|
92
|
-
<a href="#
|
|
93
|
-
<a href="#
|
|
92
|
+
<a href="#M000152">add_postamble</a>
|
|
93
|
+
<a href="#M000151">add_preamble</a>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
96
|
|
|
@@ -112,43 +112,43 @@ this is only for <a href="Eruby.html">Eruby</a>.
|
|
|
112
112
|
<div id="methods">
|
|
113
113
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
114
114
|
|
|
115
|
-
<div id="method-
|
|
116
|
-
<a name="
|
|
115
|
+
<div id="method-M000152" class="method-detail">
|
|
116
|
+
<a name="M000152"></a>
|
|
117
117
|
|
|
118
118
|
<div class="method-heading">
|
|
119
|
-
<a href="#
|
|
119
|
+
<a href="#M000152" class="method-signature">
|
|
120
120
|
<span class="method-name">add_postamble</span><span class="method-args">(src)</span>
|
|
121
121
|
</a>
|
|
122
122
|
</div>
|
|
123
123
|
|
|
124
124
|
<div class="method-description">
|
|
125
125
|
<p><a class="source-toggle" href="#"
|
|
126
|
-
onclick="toggleCode('
|
|
127
|
-
<div class="method-source-code" id="
|
|
126
|
+
onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
|
|
127
|
+
<div class="method-source-code" id="M000152-source">
|
|
128
128
|
<pre>
|
|
129
129
|
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 215</span>
|
|
130
130
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_postamble</span>(<span class="ruby-identifier">src</span>)
|
|
131
131
|
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">src</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
|
132
|
-
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"_buf\n"</span>
|
|
132
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"_buf.to_s\n"</span>
|
|
133
133
|
<span class="ruby-keyword kw">end</span>
|
|
134
134
|
</pre>
|
|
135
135
|
</div>
|
|
136
136
|
</div>
|
|
137
137
|
</div>
|
|
138
138
|
|
|
139
|
-
<div id="method-
|
|
140
|
-
<a name="
|
|
139
|
+
<div id="method-M000151" class="method-detail">
|
|
140
|
+
<a name="M000151"></a>
|
|
141
141
|
|
|
142
142
|
<div class="method-heading">
|
|
143
|
-
<a href="#
|
|
143
|
+
<a href="#M000151" class="method-signature">
|
|
144
144
|
<span class="method-name">add_preamble</span><span class="method-args">(src)</span>
|
|
145
145
|
</a>
|
|
146
146
|
</div>
|
|
147
147
|
|
|
148
148
|
<div class="method-description">
|
|
149
149
|
<p><a class="source-toggle" href="#"
|
|
150
|
-
onclick="toggleCode('
|
|
151
|
-
<div class="method-source-code" id="
|
|
150
|
+
onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
|
|
151
|
+
<div class="method-source-code" id="M000151-source">
|
|
152
152
|
<pre>
|
|
153
153
|
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 211</span>
|
|
154
154
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_preamble</span>(<span class="ruby-identifier">src</span>)
|
|
@@ -101,11 +101,10 @@ ex.
|
|
|
101
101
|
<h3 class="section-bar">Methods</h3>
|
|
102
102
|
|
|
103
103
|
<div class="name-list">
|
|
104
|
-
<a href="#
|
|
105
|
-
<a href="#
|
|
106
|
-
<a href="#
|
|
107
|
-
<a href="#
|
|
108
|
-
<a href="#M000163">result</a>
|
|
104
|
+
<a href="#M000154">convert</a>
|
|
105
|
+
<a href="#M000156">evaluate</a>
|
|
106
|
+
<a href="#M000153">new</a>
|
|
107
|
+
<a href="#M000155">result</a>
|
|
109
108
|
</div>
|
|
110
109
|
</div>
|
|
111
110
|
|
|
@@ -153,19 +152,19 @@ ex.
|
|
|
153
152
|
<div id="methods">
|
|
154
153
|
<h3 class="section-bar">Public Class methods</h3>
|
|
155
154
|
|
|
156
|
-
<div id="method-
|
|
157
|
-
<a name="
|
|
155
|
+
<div id="method-M000153" class="method-detail">
|
|
156
|
+
<a name="M000153"></a>
|
|
158
157
|
|
|
159
158
|
<div class="method-heading">
|
|
160
|
-
<a href="#
|
|
159
|
+
<a href="#M000153" class="method-signature">
|
|
161
160
|
<span class="method-name">new</span><span class="method-args">(input=nil)</span>
|
|
162
161
|
</a>
|
|
163
162
|
</div>
|
|
164
163
|
|
|
165
164
|
<div class="method-description">
|
|
166
165
|
<p><a class="source-toggle" href="#"
|
|
167
|
-
onclick="toggleCode('
|
|
168
|
-
<div class="method-source-code" id="
|
|
166
|
+
onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
|
|
167
|
+
<div class="method-source-code" id="M000153-source">
|
|
169
168
|
<pre>
|
|
170
169
|
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 20</span>
|
|
171
170
|
<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>)
|
|
@@ -178,42 +177,45 @@ ex.
|
|
|
178
177
|
|
|
179
178
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
180
179
|
|
|
181
|
-
<div id="method-
|
|
182
|
-
<a name="
|
|
180
|
+
<div id="method-M000154" class="method-detail">
|
|
181
|
+
<a name="M000154"></a>
|
|
183
182
|
|
|
184
183
|
<div class="method-heading">
|
|
185
|
-
<a href="#
|
|
184
|
+
<a href="#M000154" class="method-signature">
|
|
186
185
|
<span class="method-name">convert</span><span class="method-args">(input)</span>
|
|
187
186
|
</a>
|
|
188
187
|
</div>
|
|
189
188
|
|
|
190
189
|
<div class="method-description">
|
|
191
190
|
<p><a class="source-toggle" href="#"
|
|
192
|
-
onclick="toggleCode('
|
|
193
|
-
<div class="method-source-code" id="
|
|
191
|
+
onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
|
|
192
|
+
<div class="method-source-code" id="M000154-source">
|
|
194
193
|
<pre>
|
|
195
194
|
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 27</span>
|
|
196
195
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>)
|
|
197
|
-
<span class="ruby-identifier">src</span> = <span class="ruby-value str">"_buf =
|
|
196
|
+
<span class="ruby-identifier">src</span> = <span class="ruby-value str">"_buf = '';"</span> <span class="ruby-comment cmt"># preamble</span>
|
|
198
197
|
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
|
199
198
|
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">EMBEDDED_PATTERN</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">indicator</span>, <span class="ruby-identifier">code</span><span class="ruby-operator">|</span>
|
|
200
199
|
<span class="ruby-identifier">match</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
|
201
|
-
<span class="ruby-identifier">
|
|
202
|
-
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">
|
|
200
|
+
<span class="ruby-identifier">len</span> = <span class="ruby-identifier">match</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>
|
|
201
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">len</span>]
|
|
203
202
|
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">match</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
|
204
|
-
<span class="ruby-
|
|
203
|
+
<span class="ruby-comment cmt">#src << " _buf << '" << escape_text(text) << "';"</span>
|
|
204
|
+
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/['\\]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
|
205
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << '"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">text</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"';"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
|
205
206
|
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">indicator</span> <span class="ruby-comment cmt"># <% %></span>
|
|
206
207
|
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">";"</span>
|
|
207
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">indicator</span>
|
|
208
|
-
<span class="ruby-identifier">
|
|
209
|
-
<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>)
|
|
208
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">indicator</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'#'</span> <span class="ruby-comment cmt"># <%# %></span>
|
|
209
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> (<span class="ruby-value str">"\n"</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">count</span>(<span class="ruby-value str">"\n"</span>))
|
|
210
210
|
<span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># <%= %></span>
|
|
211
211
|
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << ("</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">").to_s;"</span>
|
|
212
212
|
<span class="ruby-keyword kw">end</span>
|
|
213
213
|
<span class="ruby-keyword kw">end</span>
|
|
214
214
|
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">$'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">input</span>
|
|
215
|
-
<span class="ruby-
|
|
216
|
-
<span class="ruby-identifier">
|
|
215
|
+
<span class="ruby-comment cmt">#src << " _buf << '" << escape_text(rest) << "';"</span>
|
|
216
|
+
<span class="ruby-identifier">rest</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/['\\]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
|
217
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << '"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">rest</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"';"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">empty?</span>
|
|
218
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n_buf.to_s\n"</span> <span class="ruby-comment cmt"># postamble</span>
|
|
217
219
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">src</span>
|
|
218
220
|
<span class="ruby-keyword kw">end</span>
|
|
219
221
|
</pre>
|
|
@@ -221,74 +223,60 @@ ex.
|
|
|
221
223
|
</div>
|
|
222
224
|
</div>
|
|
223
225
|
|
|
224
|
-
<div id="method-
|
|
225
|
-
<a name="
|
|
226
|
+
<div id="method-M000156" class="method-detail">
|
|
227
|
+
<a name="M000156"></a>
|
|
226
228
|
|
|
227
229
|
<div class="method-heading">
|
|
228
|
-
<a href="#
|
|
229
|
-
<span class="method-name">
|
|
230
|
+
<a href="#M000156" class="method-signature">
|
|
231
|
+
<span class="method-name">evaluate</span><span class="method-args">(_context=Object.new)</span>
|
|
230
232
|
</a>
|
|
231
233
|
</div>
|
|
232
234
|
|
|
233
235
|
<div class="method-description">
|
|
234
236
|
<p><a class="source-toggle" href="#"
|
|
235
|
-
onclick="toggleCode('
|
|
236
|
-
<div class="method-source-code" id="
|
|
237
|
+
onclick="toggleCode('M000156-source');return false;">[Source]</a></p>
|
|
238
|
+
<div class="method-source-code" id="M000156-source">
|
|
237
239
|
<pre>
|
|
238
|
-
<span class="ruby-comment cmt"># File erubis/tiny.rb, line
|
|
239
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
|
240
|
-
<span class="ruby-keyword kw">
|
|
240
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 62</span>
|
|
241
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">_context</span>=<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>)
|
|
242
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
|
243
|
+
<span class="ruby-identifier">_obj</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
|
244
|
+
<span class="ruby-identifier">_context</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_obj</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{k}"</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword kw">end</span>
|
|
245
|
+
<span class="ruby-identifier">_context</span> = <span class="ruby-identifier">_obj</span>
|
|
246
|
+
<span class="ruby-keyword kw">end</span>
|
|
247
|
+
<span class="ruby-identifier">_context</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-ivar">@src</span>
|
|
241
248
|
<span class="ruby-keyword kw">end</span>
|
|
242
249
|
</pre>
|
|
243
250
|
</div>
|
|
244
251
|
</div>
|
|
245
252
|
</div>
|
|
246
253
|
|
|
247
|
-
<div id="method-
|
|
248
|
-
<a name="
|
|
254
|
+
<div id="method-M000155" class="method-detail">
|
|
255
|
+
<a name="M000155"></a>
|
|
249
256
|
|
|
250
257
|
<div class="method-heading">
|
|
251
|
-
<a href="#
|
|
252
|
-
<span class="method-name">
|
|
258
|
+
<a href="#M000155" class="method-signature">
|
|
259
|
+
<span class="method-name">result</span><span class="method-args">(_binding=TOPLEVEL_BINDING)</span>
|
|
253
260
|
</a>
|
|
254
261
|
</div>
|
|
255
262
|
|
|
256
263
|
<div class="method-description">
|
|
257
|
-
<p
|
|
258
|
-
|
|
259
|
-
|
|
264
|
+
<p>
|
|
265
|
+
def escape_text(text)
|
|
266
|
+
</p>
|
|
260
267
|
<pre>
|
|
261
|
-
|
|
262
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">context</span>=<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>)
|
|
263
|
-
<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>)
|
|
264
|
-
<span class="ruby-identifier">obj</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
|
265
|
-
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{k}"</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword kw">end</span>
|
|
266
|
-
<span class="ruby-identifier">context</span> = <span class="ruby-identifier">obj</span>
|
|
267
|
-
<span class="ruby-keyword kw">end</span>
|
|
268
|
-
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-ivar">@src</span>
|
|
269
|
-
<span class="ruby-keyword kw">end</span>
|
|
268
|
+
return text.gsub!(/['\\]/, '\\\\\&') || text
|
|
270
269
|
</pre>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
<div id="method-M000163" class="method-detail">
|
|
276
|
-
<a name="M000163"></a>
|
|
277
|
-
|
|
278
|
-
<div class="method-heading">
|
|
279
|
-
<a href="#M000163" class="method-signature">
|
|
280
|
-
<span class="method-name">result</span><span class="method-args">(binding=TOPLEVEL_BINDING)</span>
|
|
281
|
-
</a>
|
|
282
|
-
</div>
|
|
283
|
-
|
|
284
|
-
<div class="method-description">
|
|
270
|
+
<p>
|
|
271
|
+
end
|
|
272
|
+
</p>
|
|
285
273
|
<p><a class="source-toggle" href="#"
|
|
286
|
-
onclick="toggleCode('
|
|
287
|
-
<div class="method-source-code" id="
|
|
274
|
+
onclick="toggleCode('M000155-source');return false;">[Source]</a></p>
|
|
275
|
+
<div class="method-source-code" id="M000155-source">
|
|
288
276
|
<pre>
|
|
289
|
-
<span class="ruby-comment cmt"># File erubis/tiny.rb, line
|
|
290
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">result</span>(<span class="ruby-identifier">
|
|
291
|
-
<span class="ruby-identifier">eval</span> <span class="ruby-ivar">@src</span>, <span class="ruby-identifier">
|
|
277
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 58</span>
|
|
278
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">result</span>(<span class="ruby-identifier">_binding</span>=<span class="ruby-constant">TOPLEVEL_BINDING</span>)
|
|
279
|
+
<span class="ruby-identifier">eval</span> <span class="ruby-ivar">@src</span>, <span class="ruby-identifier">_binding</span>
|
|
292
280
|
<span class="ruby-keyword kw">end</span>
|
|
293
281
|
</pre>
|
|
294
282
|
</div>
|
|
@@ -86,9 +86,9 @@ helper for xml
|
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
|
87
87
|
|
|
88
88
|
<div class="name-list">
|
|
89
|
-
<a href="#
|
|
90
|
-
<a href="#
|
|
91
|
-
<a href="#
|
|
89
|
+
<a href="#M000079">escape_xml</a>
|
|
90
|
+
<a href="#M000080">h</a>
|
|
91
|
+
<a href="#M000081">html_escape</a>
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
94
94
|
|
|
@@ -123,57 +123,54 @@ helper for xml
|
|
|
123
123
|
<div id="methods">
|
|
124
124
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
125
125
|
|
|
126
|
-
<div id="method-
|
|
127
|
-
<a name="
|
|
126
|
+
<div id="method-M000079" class="method-detail">
|
|
127
|
+
<a name="M000079"></a>
|
|
128
128
|
|
|
129
129
|
<div class="method-heading">
|
|
130
|
-
<a href="#
|
|
131
|
-
<span class="method-name">escape_xml</span><span class="method-args">(
|
|
130
|
+
<a href="#M000079" class="method-signature">
|
|
131
|
+
<span class="method-name">escape_xml</span><span class="method-args">(value)</span>
|
|
132
132
|
</a>
|
|
133
133
|
</div>
|
|
134
134
|
|
|
135
135
|
<div class="method-description">
|
|
136
136
|
<p><a class="source-toggle" href="#"
|
|
137
|
-
onclick="toggleCode('
|
|
138
|
-
<div class="method-source-code" id="
|
|
137
|
+
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
|
138
|
+
<div class="method-source-code" id="M000079-source">
|
|
139
139
|
<pre>
|
|
140
140
|
<span class="ruby-comment cmt"># File erubis/helper.rb, line 25</span>
|
|
141
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_xml</span>(<span class="ruby-identifier">
|
|
142
|
-
<span class="ruby-
|
|
143
|
-
<span class="ruby-comment cmt">#
|
|
144
|
-
<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[&<>"]/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-constant">ESCAPE_TABLE</span>[<span class="ruby-identifier">s</span>] } <span class="ruby-comment cmt"># or /[&<>"']/</span>
|
|
145
|
-
<span class="ruby-comment cmt">#obj.to_s.gsub(SCAN_REGEXP) { |s| ESCAPE_TABLE[s] }</span>
|
|
146
|
-
<span class="ruby-comment cmt">#obj.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] }</span>
|
|
141
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_xml</span>(<span class="ruby-identifier">value</span>)
|
|
142
|
+
<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[&<>"]/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-constant">ESCAPE_TABLE</span>[<span class="ruby-identifier">s</span>] } <span class="ruby-comment cmt"># or /[&<>"']/</span>
|
|
143
|
+
<span class="ruby-comment cmt">#value.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] }</span>
|
|
147
144
|
<span class="ruby-keyword kw">end</span>
|
|
148
145
|
</pre>
|
|
149
146
|
</div>
|
|
150
147
|
</div>
|
|
151
148
|
</div>
|
|
152
149
|
|
|
153
|
-
<div id="method-
|
|
154
|
-
<a name="
|
|
150
|
+
<div id="method-M000080" class="method-detail">
|
|
151
|
+
<a name="M000080"></a>
|
|
155
152
|
|
|
156
153
|
<div class="method-heading">
|
|
157
|
-
<span class="method-name">h</span><span class="method-args">(
|
|
154
|
+
<span class="method-name">h</span><span class="method-args">(value)</span>
|
|
158
155
|
</div>
|
|
159
156
|
|
|
160
157
|
<div class="method-description">
|
|
161
158
|
<p>
|
|
162
|
-
Alias for <a href="XmlHelper.html#
|
|
159
|
+
Alias for <a href="XmlHelper.html#M000079">escape_xml</a>
|
|
163
160
|
</p>
|
|
164
161
|
</div>
|
|
165
162
|
</div>
|
|
166
163
|
|
|
167
|
-
<div id="method-
|
|
168
|
-
<a name="
|
|
164
|
+
<div id="method-M000081" class="method-detail">
|
|
165
|
+
<a name="M000081"></a>
|
|
169
166
|
|
|
170
167
|
<div class="method-heading">
|
|
171
|
-
<span class="method-name">html_escape</span><span class="method-args">(
|
|
168
|
+
<span class="method-name">html_escape</span><span class="method-args">(value)</span>
|
|
172
169
|
</div>
|
|
173
170
|
|
|
174
171
|
<div class="method-description">
|
|
175
172
|
<p>
|
|
176
|
-
Alias for <a href="XmlHelper.html#
|
|
173
|
+
Alias for <a href="XmlHelper.html#M000079">escape_xml</a>
|
|
177
174
|
</p>
|
|
178
175
|
</div>
|
|
179
176
|
</div>
|
data/doc-api/created.rid
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Mon Feb 12 12:58:59 +0900 2007
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<title>File: README.txt</title>
|
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
-
<link rel="stylesheet" href="
|
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
|
12
12
|
<script type="text/javascript">
|
|
13
13
|
// <![CDATA[
|
|
14
14
|
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
<table class="header-table">
|
|
52
52
|
<tr class="top-aligned-row">
|
|
53
53
|
<td><strong>Path:</strong></td>
|
|
54
|
-
<td
|
|
54
|
+
<td>README.txt
|
|
55
55
|
</td>
|
|
56
56
|
</tr>
|
|
57
57
|
<tr class="top-aligned-row">
|
|
58
58
|
<td><strong>Last Update:</strong></td>
|
|
59
|
-
<td>
|
|
59
|
+
<td>Mon Feb 12 12:58:58 +0900 2007</td>
|
|
60
60
|
</tr>
|
|
61
61
|
</table>
|
|
62
62
|
</div>
|
|
@@ -71,20 +71,21 @@
|
|
|
71
71
|
<div id="description">
|
|
72
72
|
<h1>README</h1>
|
|
73
73
|
<table>
|
|
74
|
-
<tr><td valign="top">release:</td><td>$Release: 2.
|
|
74
|
+
<tr><td valign="top">release:</td><td>$Release: 2.2.0 $
|
|
75
75
|
|
|
76
76
|
</td></tr>
|
|
77
|
-
<tr><td valign="top">copyright:</td><td>copyright(c) 2006 kuwata-lab all rights reserved.
|
|
77
|
+
<tr><td valign="top">copyright:</td><td>copyright(c) 2006-2007 kuwata-lab all rights reserved.
|
|
78
78
|
|
|
79
79
|
</td></tr>
|
|
80
80
|
</table>
|
|
81
|
-
<h2>About <a href="
|
|
81
|
+
<h2>About <a href="../classes/Erubis.html">Erubis</a></h2>
|
|
82
82
|
<p>
|
|
83
|
-
<a href="
|
|
84
|
-
|
|
83
|
+
<a href="../classes/Erubis.html">Erubis</a> is an implementation of eRuby.
|
|
84
|
+
It has the following features.
|
|
85
85
|
</p>
|
|
86
86
|
<ul>
|
|
87
|
-
<li>Very fast, almost three times faster than
|
|
87
|
+
<li>Very fast, almost three times faster than <a
|
|
88
|
+
href="../classes/ERB.html">ERB</a> and even 10% faster than eruby
|
|
88
89
|
|
|
89
90
|
</li>
|
|
90
91
|
<li>Multi-language support (Ruby/PHP/C/Java/Scheme/Perl/Javascript)
|
|
@@ -118,8 +119,8 @@ datafile
|
|
|
118
119
|
</li>
|
|
119
120
|
</ul>
|
|
120
121
|
<p>
|
|
121
|
-
<a href="
|
|
122
|
-
|
|
122
|
+
<a href="../classes/Erubis.html">Erubis</a> is implemented in pure Ruby. It
|
|
123
|
+
requires Ruby 1.8 or higher.
|
|
123
124
|
</p>
|
|
124
125
|
<p>
|
|
125
126
|
See doc/users-guide.html for details.
|
|
@@ -158,24 +159,41 @@ at first, and download erubis_X.X.X.tar.bz2 and install it by setup.rb.
|
|
|
158
159
|
</pre>
|
|
159
160
|
</li>
|
|
160
161
|
</ul>
|
|
162
|
+
<h2>Ruby on Rails Support</h2>
|
|
163
|
+
<p>
|
|
164
|
+
<a href="../classes/Erubis.html">Erubis</a> supports Ruby on Rails. All you
|
|
165
|
+
have to do is to add the following code into your
|
|
166
|
+
‘config/environment.rb’ and restart web server.
|
|
167
|
+
</p>
|
|
168
|
+
<pre>
|
|
169
|
+
require 'erubis/helpers/rails_helper'
|
|
170
|
+
#Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby
|
|
171
|
+
#Erubis::Helpers::RailsHelper.init_properties = {}
|
|
172
|
+
#Erubis::Helpers::RailsHelper.show_src = false
|
|
173
|
+
</pre>
|
|
174
|
+
<p>
|
|
175
|
+
If Erubis::Helpers::RailsHelper.show_src is ture, <a
|
|
176
|
+
href="../classes/Erubis.html">Erubis</a> prints converted Ruby code into
|
|
177
|
+
log file (‘log/development.log’ or so). It is useful for debug.
|
|
178
|
+
</p>
|
|
161
179
|
<h2>Exploring Guide</h2>
|
|
162
180
|
<p>
|
|
163
181
|
If you are exploring Eruby, see the following class at first.
|
|
164
182
|
</p>
|
|
165
183
|
<ul>
|
|
166
|
-
<li><a href="
|
|
184
|
+
<li><a href="../classes/Erubis/TinyEruby.html">Erubis::TinyEruby</a>
|
|
167
185
|
(erubis/tiny.rb) — the most simple eRuby implementation.
|
|
168
186
|
|
|
169
187
|
</li>
|
|
170
|
-
<li><a href="
|
|
188
|
+
<li><a href="../classes/Erubis/Engine.html">Erubis::Engine</a>
|
|
171
189
|
(erubis/engine.rb) — base class of Eruby, Ephp, Ejava, and so on.
|
|
172
190
|
|
|
173
191
|
</li>
|
|
174
|
-
<li><a href="
|
|
192
|
+
<li><a href="../classes/Erubis/Eruby.html">Erubis::Eruby</a>
|
|
175
193
|
(erubis/engine/eruby.rb) — engine class for eRuby.
|
|
176
194
|
|
|
177
195
|
</li>
|
|
178
|
-
<li><a href="
|
|
196
|
+
<li><a href="../classes/Erubis/Converter.html">Erubis::Converter</a>
|
|
179
197
|
(erubis/converter.rb) — convert eRuby script into Ruby code.
|
|
180
198
|
|
|
181
199
|
</li>
|
|
@@ -183,15 +201,12 @@ If you are exploring Eruby, see the following class at first.
|
|
|
183
201
|
<h2>Benchmark</h2>
|
|
184
202
|
<p>
|
|
185
203
|
‘benchmark/erubybenchmark.rb’ is a benchmark script of <a
|
|
186
|
-
href="
|
|
204
|
+
href="../classes/Erubis.html">Erubis</a>. Try ‘ruby
|
|
187
205
|
erubybenchmark.rb’ in benchmark directory.
|
|
188
206
|
</p>
|
|
189
207
|
<h2>License</h2>
|
|
190
208
|
<p>
|
|
191
|
-
|
|
192
|
-
</p>
|
|
193
|
-
<p>
|
|
194
|
-
If you need looser license, please suggest me.
|
|
209
|
+
MIT License
|
|
195
210
|
</p>
|
|
196
211
|
<h2>Author</h2>
|
|
197
212
|
<p>
|