doc-api/classes/Erubis/Main.html in erubis-2.0.1 vs doc-api/classes/Erubis/Main.html in erubis-2.1.0
- old
+ new
@@ -96,13 +96,13 @@
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
- <a href="#M000104">execute</a>
- <a href="#M000102">main</a>
- <a href="#M000103">new</a>
+ <a href="#M000173">execute</a>
+ <a href="#M000171">main</a>
+ <a href="#M000172">new</a>
</div>
</div>
</div>
@@ -120,23 +120,23 @@
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
- <div id="method-M000102" class="method-detail">
- <a name="M000102"></a>
+ <div id="method-M000171" class="method-detail">
+ <a name="M000171"></a>
<div class="method-heading">
- <a href="#M000102" class="method-signature">
+ <a href="#M000171" class="method-signature">
<span class="method-name">main</span><span class="method-args">(argv=ARGV)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000102-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000102-source">
+ onclick="toggleCode('M000171-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000171-source">
<pre>
<span class="ruby-comment cmt"># File erubis/main.rb, line 40</span>
<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>)
<span class="ruby-identifier">status</span> = <span class="ruby-value">0</span>
<span class="ruby-keyword kw">begin</span>
@@ -150,23 +150,23 @@
</pre>
</div>
</div>
</div>
- <div id="method-M000103" class="method-detail">
- <a name="M000103"></a>
+ <div id="method-M000172" class="method-detail">
+ <a name="M000172"></a>
<div class="method-heading">
- <a href="#M000103" class="method-signature">
+ <a href="#M000172" class="method-signature">
<span class="method-name">new</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000103-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000103-source">
+ onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000172-source">
<pre>
<span class="ruby-comment cmt"># File erubis/main.rb, line 51</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
<span class="ruby-ivar">@single_options</span> = <span class="ruby-value str">"hvxTtSbeB"</span>
<span class="ruby-ivar">@arg_options</span> = <span class="ruby-value str">"pcrfKIlaE"</span>
@@ -200,23 +200,23 @@
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
- <div id="method-M000104" class="method-detail">
- <a name="M000104"></a>
+ <div id="method-M000173" class="method-detail">
+ <a name="M000173"></a>
<div class="method-heading">
- <a href="#M000104" class="method-signature">
+ <a href="#M000173" class="method-signature">
<span class="method-name">execute</span><span class="method-args">(argv=ARGV)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000104-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000104-source">
+ onclick="toggleCode('M000173-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000173-source">
<pre>
<span class="ruby-comment cmt"># File erubis/main.rb, line 81</span>
<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>)
<span class="ruby-comment cmt">## parse command-line options</span>
<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>)
@@ -249,52 +249,54 @@
<span class="ruby-identifier">require</span> <span class="ruby-identifier">library</span>
<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>
<span class="ruby-comment cmt">## action</span>
<span class="ruby-identifier">action</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">action</span>
- <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>
+ <span class="ruby-identifier">action</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'convert'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">source</span>
<span class="ruby-comment cmt">## lang</span>
<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>
- <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>
+ <span class="ruby-identifier">action</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'convert'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">lang</span>
<span class="ruby-comment cmt">## class name of Eruby</span>
<span class="ruby-identifier">classname</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">class</span>
- <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>)
+ <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>, <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:pi</span>])
<span class="ruby-comment cmt">## kanji code</span>
<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>
<span class="ruby-comment cmt">## read context values from yaml file</span>
<span class="ruby-identifier">yamlfiles</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">yamlfiles</span>
<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>)
<span class="ruby-comment cmt">## properties for engine</span>
+ <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:escape</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">escape</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">properties</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:escape</span>)
<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>
<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>
<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>
+ <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:pi</span>] = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:pi</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
<span class="ruby-comment cmt">## create engine and extend enhancers</span>
<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>)
<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>)
- <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>
+ <span class="ruby-comment cmt">#enhancers.push(Erubis::EscapeEnhancer) if opts.escape</span>
<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>
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-identifier">enhancer</span>)
<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>
<span class="ruby-keyword kw">end</span>
- <span class="ruby-comment cmt">## compile and execute</span>
+ <span class="ruby-comment cmt">## convert and execute</span>
<span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">nil</span>
<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>
<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>
<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>)
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename</span>
- <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>))
+ <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">convert!</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>))
<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>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">else</span>
<span class="ruby-identifier">engine</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-value str">'(stdin)'</span>
- <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">compile!</span>(<span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">read</span>())
+ <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">convert!</span>(<span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">read</span>())
<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>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span>
</pre>
\ No newline at end of file