erubis 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +45 -18
- data/README.txt +80 -0
- data/benchmark/erubybench-lib.rb +189 -0
- data/benchmark/erubybench.rb +364 -0
- data/benchmark/erubybench.rhtml +61 -0
- data/benchmark/erubybench.yaml +61 -0
- data/bin/erubis +4 -180
- data/contrib/erubis +2297 -0
- data/contrib/inline-require +151 -0
- data/doc-api/classes/Erubis.html +236 -0
- data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +175 -0
- data/doc-api/classes/Erubis/ArrayBufferEruby.html +120 -0
- data/doc-api/classes/Erubis/ArrayEnhancer.html +174 -0
- data/doc-api/classes/Erubis/ArrayEruby.html +120 -0
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +212 -0
- data/doc-api/classes/Erubis/BiPatternEruby.html +120 -0
- data/doc-api/classes/Erubis/CommandOptionError.html +113 -0
- data/doc-api/classes/Erubis/Context.html +249 -0
- data/doc-api/classes/Erubis/Ec.html +399 -0
- data/doc-api/classes/Erubis/Ejava.html +366 -0
- data/doc-api/classes/Erubis/Ejavascript.html +390 -0
- data/doc-api/classes/Erubis/Engine.html +711 -0
- data/doc-api/classes/Erubis/Eperl.html +350 -0
- data/doc-api/classes/Erubis/Ephp.html +308 -0
- data/doc-api/classes/Erubis/ErubisError.html +117 -0
- data/doc-api/classes/Erubis/Eruby.html +310 -0
- data/doc-api/classes/Erubis/EscapeEnhancer.html +167 -0
- data/doc-api/classes/Erubis/EscapedEc.html +120 -0
- data/doc-api/classes/Erubis/EscapedEjava.html +120 -0
- data/doc-api/classes/Erubis/EscapedEjavascript.html +120 -0
- data/doc-api/classes/Erubis/EscapedEperl.html +120 -0
- data/doc-api/classes/Erubis/EscapedEphp.html +120 -0
- data/doc-api/classes/Erubis/EscapedEruby.html +127 -0
- data/doc-api/classes/Erubis/EscapedEscheme.html +120 -0
- data/doc-api/classes/Erubis/Escheme.html +389 -0
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +264 -0
- data/doc-api/classes/Erubis/HeaderFooterEruby.html +120 -0
- data/doc-api/classes/Erubis/Main.html +318 -0
- data/doc-api/classes/Erubis/NoTextEnhancer.html +159 -0
- data/doc-api/classes/Erubis/NoTextEruby.html +120 -0
- data/doc-api/classes/Erubis/OptimizedEruby.html +445 -0
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +163 -0
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +174 -0
- data/doc-api/classes/Erubis/PercentLineEruby.html +120 -0
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +212 -0
- data/doc-api/classes/Erubis/PrintEnabledEruby.html +120 -0
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +244 -0
- data/doc-api/classes/Erubis/PrintOutEruby.html +120 -0
- data/doc-api/classes/Erubis/PrintOutSimplifiedEruby.html +121 -0
- data/doc-api/classes/Erubis/SimplifiedEruby.html +120 -0
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +185 -0
- data/doc-api/classes/Erubis/StdoutEnhancer.html +173 -0
- data/doc-api/classes/Erubis/StdoutEruby.html +120 -0
- data/doc-api/classes/Erubis/StdoutSimplifiedEruby.html +121 -0
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +174 -0
- data/doc-api/classes/Erubis/StringBufferEruby.html +120 -0
- data/doc-api/classes/Erubis/StringIOEruby.html +120 -0
- data/doc-api/classes/Erubis/TinyEruby.html +305 -0
- data/doc-api/classes/Erubis/XmlEruby.html +130 -0
- data/doc-api/classes/Erubis/XmlHelper.html +193 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +214 -0
- data/doc-api/files/erubis/engine/ec_rb.html +115 -0
- data/doc-api/files/erubis/engine/ejava_rb.html +115 -0
- data/doc-api/files/erubis/engine/ejavascript_rb.html +115 -0
- data/doc-api/files/erubis/engine/enhanced_rb.html +115 -0
- data/doc-api/files/erubis/engine/eperl_rb.html +115 -0
- data/doc-api/files/erubis/engine/ephp_rb.html +115 -0
- data/doc-api/files/erubis/engine/eruby_rb.html +115 -0
- data/doc-api/files/erubis/engine/escheme_rb.html +115 -0
- data/doc-api/files/erubis/engine/optimized_rb.html +114 -0
- data/doc-api/files/erubis/engine_rb.html +114 -0
- data/doc-api/files/erubis/enhancer_rb.html +114 -0
- data/doc-api/files/erubis/helper_rb.html +107 -0
- data/doc-api/files/erubis/local-setting_rb.html +107 -0
- data/doc-api/files/erubis/main_rb.html +125 -0
- data/doc-api/files/erubis/tiny_rb.html +107 -0
- data/doc-api/files/erubis_rb.html +118 -0
- data/doc-api/fr_class_index.html +77 -0
- data/doc-api/fr_file_index.html +43 -0
- data/doc-api/fr_method_index.html +157 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/doc/users-guide.html +1507 -375
- data/examples/Makefile +53 -0
- data/examples/example.ec +24 -0
- data/examples/example.ejava +41 -0
- data/examples/example.ejavascript +16 -0
- data/examples/example.eperl +16 -0
- data/examples/example.ephp +17 -0
- data/examples/example.eruby +15 -0
- data/examples/example.escheme +26 -0
- data/lib/erubis.rb +37 -269
- data/lib/erubis/engine.rb +260 -0
- data/lib/erubis/engine/ec.rb +106 -0
- data/lib/erubis/engine/ejava.rb +101 -0
- data/lib/erubis/engine/ejavascript.rb +104 -0
- data/lib/erubis/engine/enhanced.rb +102 -0
- data/lib/erubis/engine/eperl.rb +83 -0
- data/lib/erubis/engine/ephp.rb +84 -0
- data/lib/erubis/engine/eruby.rb +91 -0
- data/lib/erubis/engine/escheme.rb +96 -0
- data/lib/erubis/engine/optimized.rb +114 -0
- data/lib/erubis/enhancer.rb +487 -0
- data/lib/erubis/helper.rb +53 -0
- data/lib/erubis/local-setting.rb +10 -0
- data/lib/erubis/main.rb +368 -0
- data/lib/erubis/tiny.rb +65 -0
- data/test/assert-text-equal.rb +45 -0
- data/test/test-bin.rb +222 -45
- data/test/test-engines.rb +343 -0
- data/test/test-erubis.rb +836 -501
- data/test/test.rb +27 -0
- data/test/testutil.rb +86 -0
- metadata +131 -8
- data/README +0 -50
@@ -0,0 +1,264 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: Erubis::HeaderFooterEnhancer</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Erubis::HeaderFooterEnhancer</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/erubis/enhancer_rb.html">
|
59
|
+
erubis/enhancer.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<dl>
|
77
|
+
<dt>experimental</dt><dd>allow header and footer in eRuby script
|
78
|
+
|
79
|
+
</dd>
|
80
|
+
</dl>
|
81
|
+
<p>
|
82
|
+
ex.
|
83
|
+
</p>
|
84
|
+
<pre>
|
85
|
+
====================
|
86
|
+
## without header and footer
|
87
|
+
$ cat ex1.eruby
|
88
|
+
<% def list_items(list) %>
|
89
|
+
<% for item in list %>
|
90
|
+
<li><%= item %></li>
|
91
|
+
<% end %>
|
92
|
+
<% end %>
|
93
|
+
|
94
|
+
$ erubis -s ex1.eruby
|
95
|
+
_buf = []; def list_items(list)
|
96
|
+
; for item in list
|
97
|
+
; _buf << '<li>'; _buf << ( item ).to_s; _buf << '</li>
|
98
|
+
'; end
|
99
|
+
; end
|
100
|
+
;
|
101
|
+
_buf.join
|
102
|
+
|
103
|
+
## with header and footer
|
104
|
+
$ cat ex2.eruby
|
105
|
+
<!--#header:
|
106
|
+
def list_items(list)
|
107
|
+
#-->
|
108
|
+
<% for item in list %>
|
109
|
+
<li><%= item %></li>
|
110
|
+
<% end %>
|
111
|
+
<!--#footer:
|
112
|
+
end
|
113
|
+
#-->
|
114
|
+
|
115
|
+
$ erubis -s -c HeaderFooterEruby ex4.eruby
|
116
|
+
|
117
|
+
def list_items(list)
|
118
|
+
_buf = []; _buf << '
|
119
|
+
'; for item in list
|
120
|
+
; _buf << '<li>'; _buf << ( item ).to_s; _buf << '</li>
|
121
|
+
'; end
|
122
|
+
; _buf << '
|
123
|
+
';
|
124
|
+
_buf.join
|
125
|
+
end
|
126
|
+
|
127
|
+
====================
|
128
|
+
</pre>
|
129
|
+
<p>
|
130
|
+
this is language-independent.
|
131
|
+
</p>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<div id="method-list">
|
139
|
+
<h3 class="section-bar">Methods</h3>
|
140
|
+
|
141
|
+
<div class="name-list">
|
142
|
+
<a href="#M000009">add_text</a>
|
143
|
+
<a href="#M000010">compile</a>
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
</div>
|
148
|
+
|
149
|
+
|
150
|
+
<!-- if includes -->
|
151
|
+
|
152
|
+
<div id="section">
|
153
|
+
|
154
|
+
|
155
|
+
<div id="constants-list">
|
156
|
+
<h3 class="section-bar">Constants</h3>
|
157
|
+
|
158
|
+
<div class="name-list">
|
159
|
+
<table summary="Constants">
|
160
|
+
<tr class="top-aligned-row context-row">
|
161
|
+
<td class="context-item-name">HEADER_FOOTER_PATTERN</td>
|
162
|
+
<td>=</td>
|
163
|
+
<td class="context-item-value">/(.*?)(^[ \t]*)?<!--\#(\w+):(.*?)\#-->([ \t]*\r?\n)?/m</td>
|
164
|
+
</tr>
|
165
|
+
</table>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<div id="attribute-list">
|
172
|
+
<h3 class="section-bar">Attributes</h3>
|
173
|
+
|
174
|
+
<div class="name-list">
|
175
|
+
<table>
|
176
|
+
<tr class="top-aligned-row context-row">
|
177
|
+
<td class="context-item-name">footer</td>
|
178
|
+
<td class="context-item-value"> [RW] </td>
|
179
|
+
<td class="context-item-desc"></td>
|
180
|
+
</tr>
|
181
|
+
<tr class="top-aligned-row context-row">
|
182
|
+
<td class="context-item-name">header</td>
|
183
|
+
<td class="context-item-value"> [RW] </td>
|
184
|
+
<td class="context-item-desc"></td>
|
185
|
+
</tr>
|
186
|
+
</table>
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
<!-- if method_list -->
|
193
|
+
<div id="methods">
|
194
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
195
|
+
|
196
|
+
<div id="method-M000009" class="method-detail">
|
197
|
+
<a name="M000009"></a>
|
198
|
+
|
199
|
+
<div class="method-heading">
|
200
|
+
<a href="#M000009" class="method-signature">
|
201
|
+
<span class="method-name">add_text</span><span class="method-args">(src, text)</span>
|
202
|
+
</a>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div class="method-description">
|
206
|
+
<p><a class="source-toggle" href="#"
|
207
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
208
|
+
<div class="method-source-code" id="M000009-source">
|
209
|
+
<pre>
|
210
|
+
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 464</span>
|
211
|
+
<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>)
|
212
|
+
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">HEADER_FOOTER_PATTERN</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">txt</span>, <span class="ruby-identifier">lspace</span>, <span class="ruby-identifier">word</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">rspace</span><span class="ruby-operator">|</span>
|
213
|
+
<span class="ruby-identifier">flag_trim</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>
|
214
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">txt</span>)
|
215
|
+
<span class="ruby-identifier">content</span> = <span class="ruby-node">"#{lspace}#{content}#{rspace}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flag_trim</span>
|
216
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">lspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">flag_trim</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">lspace</span>
|
217
|
+
<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{word}"</span>, <span class="ruby-identifier">content</span>)
|
218
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">flag_trim</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">rspace</span>
|
219
|
+
<span class="ruby-keyword kw">end</span>
|
220
|
+
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">$'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">text</span>
|
221
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">rest</span>)
|
222
|
+
<span class="ruby-keyword kw">end</span>
|
223
|
+
</pre>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
<div id="method-M000010" class="method-detail">
|
229
|
+
<a name="M000010"></a>
|
230
|
+
|
231
|
+
<div class="method-heading">
|
232
|
+
<a href="#M000010" class="method-signature">
|
233
|
+
<span class="method-name">compile</span><span class="method-args">(input)</span>
|
234
|
+
</a>
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div class="method-description">
|
238
|
+
<p><a class="source-toggle" href="#"
|
239
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
240
|
+
<div class="method-source-code" id="M000010-source">
|
241
|
+
<pre>
|
242
|
+
<span class="ruby-comment cmt"># File erubis/enhancer.rb, line 479</span>
|
243
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">input</span>)
|
244
|
+
<span class="ruby-identifier">source</span> = <span class="ruby-keyword kw">super</span>
|
245
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@src</span> = <span class="ruby-node">"#{@header}#{source}#{@footer}"</span>
|
246
|
+
<span class="ruby-keyword kw">end</span>
|
247
|
+
</pre>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
|
253
|
+
</div>
|
254
|
+
|
255
|
+
|
256
|
+
</div>
|
257
|
+
|
258
|
+
|
259
|
+
<div id="validator-badges">
|
260
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
</body>
|
264
|
+
</html>
|
@@ -0,0 +1,120 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Erubis::HeaderFooterEruby</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Erubis::HeaderFooterEruby</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/erubis/engine/enhanced_rb.html">
|
59
|
+
erubis/engine/enhanced.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="Eruby.html">
|
69
|
+
Eruby
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
<!-- if includes -->
|
92
|
+
<div id="includes">
|
93
|
+
<h3 class="section-bar">Included Modules</h3>
|
94
|
+
|
95
|
+
<div id="includes-list">
|
96
|
+
<span class="include-name"><a href="HeaderFooterEnhancer.html">HeaderFooterEnhancer</a></span>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
<div id="section">
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if method_list -->
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
|
115
|
+
<div id="validator-badges">
|
116
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
</body>
|
120
|
+
</html>
|
@@ -0,0 +1,318 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Erubis::Main</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Erubis::Main</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/erubis/main_rb.html">
|
59
|
+
erubis/main.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
main class of command
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
ex.
|
87
|
+
</p>
|
88
|
+
<pre>
|
89
|
+
Main.main(ARGV)
|
90
|
+
</pre>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div id="method-list">
|
98
|
+
<h3 class="section-bar">Methods</h3>
|
99
|
+
|
100
|
+
<div class="name-list">
|
101
|
+
<a href="#M000099">execute</a>
|
102
|
+
<a href="#M000097">main</a>
|
103
|
+
<a href="#M000098">new</a>
|
104
|
+
</div>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
<!-- if includes -->
|
111
|
+
|
112
|
+
<div id="section">
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<!-- if method_list -->
|
122
|
+
<div id="methods">
|
123
|
+
<h3 class="section-bar">Public Class methods</h3>
|
124
|
+
|
125
|
+
<div id="method-M000097" class="method-detail">
|
126
|
+
<a name="M000097"></a>
|
127
|
+
|
128
|
+
<div class="method-heading">
|
129
|
+
<a href="#M000097" class="method-signature">
|
130
|
+
<span class="method-name">main</span><span class="method-args">(argv=ARGV)</span>
|
131
|
+
</a>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<div class="method-description">
|
135
|
+
<p><a class="source-toggle" href="#"
|
136
|
+
onclick="toggleCode('M000097-source');return false;">[Source]</a></p>
|
137
|
+
<div class="method-source-code" id="M000097-source">
|
138
|
+
<pre>
|
139
|
+
<span class="ruby-comment cmt"># File erubis/main.rb, line 40</span>
|
140
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">main</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>)
|
141
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-value">0</span>
|
142
|
+
<span class="ruby-keyword kw">begin</span>
|
143
|
+
<span class="ruby-constant">Main</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-constant">ARGV</span>)
|
144
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CommandOptionError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
145
|
+
<span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">message</span>
|
146
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-value">1</span>
|
147
|
+
<span class="ruby-keyword kw">end</span>
|
148
|
+
<span class="ruby-identifier">exit</span>(<span class="ruby-identifier">status</span>)
|
149
|
+
<span class="ruby-keyword kw">end</span>
|
150
|
+
</pre>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
</div>
|
154
|
+
|
155
|
+
<div id="method-M000098" class="method-detail">
|
156
|
+
<a name="M000098"></a>
|
157
|
+
|
158
|
+
<div class="method-heading">
|
159
|
+
<a href="#M000098" class="method-signature">
|
160
|
+
<span class="method-name">new</span><span class="method-args">()</span>
|
161
|
+
</a>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<div class="method-description">
|
165
|
+
<p><a class="source-toggle" href="#"
|
166
|
+
onclick="toggleCode('M000098-source');return false;">[Source]</a></p>
|
167
|
+
<div class="method-source-code" id="M000098-source">
|
168
|
+
<pre>
|
169
|
+
<span class="ruby-comment cmt"># File erubis/main.rb, line 51</span>
|
170
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
171
|
+
<span class="ruby-ivar">@single_options</span> = <span class="ruby-value str">"hvxTtSbeB"</span>
|
172
|
+
<span class="ruby-ivar">@arg_options</span> = <span class="ruby-value str">"pcrfKIlaE"</span>
|
173
|
+
<span class="ruby-ivar">@option_names</span> = {
|
174
|
+
<span class="ruby-value">?h</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:help</span>,
|
175
|
+
<span class="ruby-value">?v</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:version</span>,
|
176
|
+
<span class="ruby-value">?x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:source</span>,
|
177
|
+
<span class="ruby-value">?T</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:notrim</span>,
|
178
|
+
<span class="ruby-value">?t</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:untabify</span>,
|
179
|
+
<span class="ruby-value">?S</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:intern</span>,
|
180
|
+
<span class="ruby-value">?b</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:bodyonly</span>,
|
181
|
+
<span class="ruby-value">?B</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:binding</span>,
|
182
|
+
<span class="ruby-value">?p</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:pattern</span>,
|
183
|
+
<span class="ruby-value">?c</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:class</span>,
|
184
|
+
<span class="ruby-value">?e</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:escape</span>,
|
185
|
+
<span class="ruby-value">?r</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:requires</span>,
|
186
|
+
<span class="ruby-value">?f</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:yamlfiles</span>,
|
187
|
+
<span class="ruby-value">?K</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:kanji</span>,
|
188
|
+
<span class="ruby-value">?I</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:includes</span>,
|
189
|
+
<span class="ruby-value">?l</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:lang</span>,
|
190
|
+
<span class="ruby-value">?a</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:action</span>,
|
191
|
+
<span class="ruby-value">?E</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:enhancers</span>,
|
192
|
+
}
|
193
|
+
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@single_options</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@arg_options</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@option_names</span>.<span class="ruby-identifier">length</span>
|
194
|
+
(<span class="ruby-ivar">@single_options</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@arg_options</span>).<span class="ruby-identifier">each_byte</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span><span class="ruby-operator">|</span>
|
195
|
+
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@option_names</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">ch</span>)
|
196
|
+
<span class="ruby-keyword kw">end</span>
|
197
|
+
<span class="ruby-keyword kw">end</span>
|
198
|
+
</pre>
|
199
|
+
</div>
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
204
|
+
|
205
|
+
<div id="method-M000099" class="method-detail">
|
206
|
+
<a name="M000099"></a>
|
207
|
+
|
208
|
+
<div class="method-heading">
|
209
|
+
<a href="#M000099" class="method-signature">
|
210
|
+
<span class="method-name">execute</span><span class="method-args">(argv=ARGV)</span>
|
211
|
+
</a>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
<div class="method-description">
|
215
|
+
<p><a class="source-toggle" href="#"
|
216
|
+
onclick="toggleCode('M000099-source');return false;">[Source]</a></p>
|
217
|
+
<div class="method-source-code" id="M000099-source">
|
218
|
+
<pre>
|
219
|
+
<span class="ruby-comment cmt"># File erubis/main.rb, line 81</span>
|
220
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>)
|
221
|
+
<span class="ruby-comment cmt">## parse command-line options</span>
|
222
|
+
<span class="ruby-identifier">options</span>, <span class="ruby-identifier">properties</span> = <span class="ruby-identifier">parse_argv</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-ivar">@single_options</span>, <span class="ruby-ivar">@arg_options</span>)
|
223
|
+
<span class="ruby-identifier">filenames</span> = <span class="ruby-identifier">argv</span>
|
224
|
+
<span class="ruby-identifier">options</span>[<span class="ruby-value">?h</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:help</span>]
|
225
|
+
<span class="ruby-identifier">opts</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
226
|
+
<span class="ruby-identifier">arr</span> = <span class="ruby-ivar">@option_names</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-node">"def #{name}; @#{name}; end\n"</span> }
|
227
|
+
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-identifier">arr</span>.<span class="ruby-identifier">join</span>
|
228
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
229
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-ivar">@option_names</span>[<span class="ruby-identifier">ch</span>]
|
230
|
+
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{name}"</span>, <span class="ruby-identifier">val</span>)
|
231
|
+
<span class="ruby-keyword kw">end</span>
|
232
|
+
|
233
|
+
<span class="ruby-comment cmt">## help, version, enhancer list</span>
|
234
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">version</span>
|
235
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">version</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">version</span>
|
236
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">usage</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
|
237
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">show_properties</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
|
238
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">show_enhancers</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
|
239
|
+
<span class="ruby-keyword kw">return</span>
|
240
|
+
<span class="ruby-keyword kw">end</span>
|
241
|
+
|
242
|
+
<span class="ruby-comment cmt">## include path</span>
|
243
|
+
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">includes</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
|
244
|
+
<span class="ruby-identifier">$:</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">path</span>
|
245
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">includes</span>
|
246
|
+
|
247
|
+
<span class="ruby-comment cmt">## require library</span>
|
248
|
+
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">requires</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">library</span><span class="ruby-operator">|</span>
|
249
|
+
<span class="ruby-identifier">require</span> <span class="ruby-identifier">library</span>
|
250
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">requires</span>
|
251
|
+
|
252
|
+
<span class="ruby-comment cmt">## action</span>
|
253
|
+
<span class="ruby-identifier">action</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">action</span>
|
254
|
+
<span class="ruby-identifier">action</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'compile'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">source</span>
|
255
|
+
|
256
|
+
<span class="ruby-comment cmt">## lang</span>
|
257
|
+
<span class="ruby-identifier">lang</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">lang</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'ruby'</span>
|
258
|
+
<span class="ruby-identifier">action</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'compile'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">lang</span>
|
259
|
+
|
260
|
+
<span class="ruby-comment cmt">## class name of Eruby</span>
|
261
|
+
<span class="ruby-identifier">classname</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">class</span>
|
262
|
+
<span class="ruby-identifier">klass</span> = <span class="ruby-identifier">get_classobj</span>(<span class="ruby-identifier">classname</span>, <span class="ruby-identifier">lang</span>)
|
263
|
+
|
264
|
+
<span class="ruby-comment cmt">## kanji code</span>
|
265
|
+
<span class="ruby-identifier">$KCODE</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">kanji</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">kanji</span>
|
266
|
+
|
267
|
+
<span class="ruby-comment cmt">## read context values from yaml file</span>
|
268
|
+
<span class="ruby-identifier">yamlfiles</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">yamlfiles</span>
|
269
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-identifier">load_yamlfiles</span>(<span class="ruby-identifier">yamlfiles</span>, <span class="ruby-identifier">opts</span>)
|
270
|
+
|
271
|
+
<span class="ruby-comment cmt">## properties for engine</span>
|
272
|
+
<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:pattern</span>] = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">pattern</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">pattern</span>
|
273
|
+
<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:trim</span>] = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">notrim</span>
|
274
|
+
<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:preamble</span>] = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:postamble</span>] = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">bodyonly</span>
|
275
|
+
|
276
|
+
<span class="ruby-comment cmt">## create engine and extend enhancers</span>
|
277
|
+
<span class="ruby-identifier">engine</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>)
|
278
|
+
<span class="ruby-identifier">enhancers</span> = <span class="ruby-identifier">get_enhancers</span>(<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">enhancers</span>)
|
279
|
+
<span class="ruby-identifier">enhancers</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">EscapeEnhancer</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">escape</span>
|
280
|
+
<span class="ruby-identifier">enhancers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">enhancer</span><span class="ruby-operator">|</span>
|
281
|
+
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-identifier">enhancer</span>)
|
282
|
+
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">bipattern</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:bipattern</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enhancer</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">BiPatternEnhancer</span>
|
283
|
+
<span class="ruby-keyword kw">end</span>
|
284
|
+
|
285
|
+
<span class="ruby-comment cmt">## compile and execute</span>
|
286
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">nil</span>
|
287
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filenames</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">empty?</span>
|
288
|
+
<span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
289
|
+
<span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">CommandOptionError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{filename}: file not found."</span>)
|
290
|
+
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename</span>
|
291
|
+
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">compile!</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>))
|
292
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">val</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> = <span class="ruby-identifier">do_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">engine</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">opts</span>)
|
293
|
+
<span class="ruby-keyword kw">end</span>
|
294
|
+
<span class="ruby-keyword kw">else</span>
|
295
|
+
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-value str">'(stdin)'</span>
|
296
|
+
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">compile!</span>(<span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">read</span>())
|
297
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">val</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> = <span class="ruby-identifier">do_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">engine</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">opts</span>)
|
298
|
+
<span class="ruby-keyword kw">end</span>
|
299
|
+
|
300
|
+
<span class="ruby-keyword kw">end</span>
|
301
|
+
</pre>
|
302
|
+
</div>
|
303
|
+
</div>
|
304
|
+
</div>
|
305
|
+
|
306
|
+
|
307
|
+
</div>
|
308
|
+
|
309
|
+
|
310
|
+
</div>
|
311
|
+
|
312
|
+
|
313
|
+
<div id="validator-badges">
|
314
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
</body>
|
318
|
+
</html>
|