instiki/vendor/plugins/erubis/doc-api/classes/Erubis/Converter.html

283 lines
12 KiB
HTML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Erubis::Converter</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Erubis::Converter</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/erubis/converter_rb.html">
erubis/converter.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Converter.html#M000063">convert</a>
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000063">convert</a>&nbsp;&nbsp;
<a href="#M000065">convert_input</a>&nbsp;&nbsp;
<a href="#M000064">detect_spaces_at_bol</a>&nbsp;&nbsp;
<a href="#M000062">init_converter</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">escape</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">postamble</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">preamble</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000063" class="method-detail">
<a name="M000063"></a>
<div class="method-heading">
<a href="#M000063" class="method-signature">
<span class="method-name">convert</span><span class="method-args">(input)</span>
</a>
</div>
<div class="method-description">
<p>
<a href="Converter.html#M000063">convert</a> input string into target
language
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000063-source">
<pre>
<span class="ruby-comment cmt"># File erubis/converter.rb, line 33</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>)
<span class="ruby-identifier">codebuf</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-comment cmt"># or []</span>
<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">codebuf</span>) <span class="ruby-operator">:</span> (<span class="ruby-ivar">@preamble</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">codebuf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@preamble</span>))
<span class="ruby-identifier">convert_input</span>(<span class="ruby-identifier">codebuf</span>, <span class="ruby-identifier">input</span>)
<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">codebuf</span>) <span class="ruby-operator">:</span> (<span class="ruby-ivar">@postamble</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">codebuf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@postamble</span>))
<span class="ruby-ivar">@_proc</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># clear cached proc object</span>
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">codebuf</span> <span class="ruby-comment cmt"># or codebuf.join()</span>
<span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000062" class="method-detail">
<a name="M000062"></a>
<div class="method-heading">
<a href="#M000062" class="method-signature">
<span class="method-name">init_converter</span><span class="method-args">(properties={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000062-source">
<pre>
<span class="ruby-comment cmt"># File erubis/converter.rb, line 26</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">init_converter</span>(<span class="ruby-identifier">properties</span>={})
<span class="ruby-ivar">@preamble</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:preamble</span>]
<span class="ruby-ivar">@postamble</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:postamble</span>]
<span class="ruby-ivar">@escape</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:escape</span>]
<span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Protected Instance methods</h3>
<div id="method-M000065" class="method-detail">
<a name="M000065"></a>
<div class="method-heading">
<a href="#M000065" class="method-signature">
<span class="method-name">convert_input</span><span class="method-args">(codebuf, input)</span>
</a>
</div>
<div class="method-description">
<p>
(abstract) <a href="Converter.html#M000063">convert</a> input to code
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000065-source">
<pre>
<span class="ruby-comment cmt"># File erubis/converter.rb, line 77</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert_input</span>(<span class="ruby-identifier">codebuf</span>, <span class="ruby-identifier">input</span>)
<span class="ruby-identifier">not_implemented</span>
<span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000064" class="method-detail">
<a name="M000064"></a>
<div class="method-heading">
<a href="#M000064" class="method-signature">
<span class="method-name">detect_spaces_at_bol</span><span class="method-args">(text, is_bol)</span>
</a>
</div>
<div class="method-description">
<p>
detect spaces at beginning of line
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000064-source">
<pre>
<span class="ruby-comment cmt"># File erubis/converter.rb, line 47</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">detect_spaces_at_bol</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">is_bol</span>)
<span class="ruby-identifier">lspace</span> = <span class="ruby-keyword kw">nil</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">lspace</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_bol</span>
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">text</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
<span class="ruby-identifier">lspace</span> = <span class="ruby-value str">&quot;&quot;</span>
<span class="ruby-keyword kw">else</span>
<span class="ruby-identifier">rindex</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value">?\n</span>)
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rindex</span>
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">text</span>[<span class="ruby-identifier">rindex</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[ \t]*\z/</span>
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">s</span>
<span class="ruby-comment cmt">#text = text[0..rindex]</span>
<span class="ruby-identifier">text</span>[<span class="ruby-identifier">rindex</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] = <span class="ruby-value str">''</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">else</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_bol</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[ \t]*\z/</span>
<span class="ruby-comment cmt">#lspace = text</span>
<span class="ruby-comment cmt">#text = nil</span>
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">dup</span>
<span class="ruby-identifier">text</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] = <span class="ruby-value str">''</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">lspace</span>
<span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>