a5e08f7bcc
I installed the rails_xss plugin, for the main purpose of seeing what will break with Rails 3.0 (where the behaviour of the plugin is the default). I think I've fixed everything, but let me know if you see stuff that is HTML-escaped, which shouldn't be. As a side benefit, we now use Erubis, rather than ERB, to render templates. They tell me it's faster ...
227 lines
9.7 KiB
HTML
227 lines
9.7 KiB
HTML
<?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::RubyEvaluator</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::RubyEvaluator</td>
|
|
</tr>
|
|
<tr class="top-aligned-row">
|
|
<td><strong>In:</strong></td>
|
|
<td>
|
|
<a href="../../files/erubis/evaluator_rb.html">
|
|
erubis/evaluator.rb
|
|
</a>
|
|
<br />
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
</div>
|
|
<!-- banner header -->
|
|
|
|
<div id="bodyContent">
|
|
|
|
|
|
|
|
<div id="contextContent">
|
|
|
|
<div id="description">
|
|
<p>
|
|
evaluator for Ruby
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div id="method-list">
|
|
<h3 class="section-bar">Methods</h3>
|
|
|
|
<div class="name-list">
|
|
<a href="#M000197">def_method</a>
|
|
<a href="#M000196">evaluate</a>
|
|
<a href="#M000195">result</a>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<!-- if includes -->
|
|
<div id="includes">
|
|
<h3 class="section-bar">Included Modules</h3>
|
|
|
|
<div id="includes-list">
|
|
<span class="include-name"><a href="Evaluator.html">Evaluator</a></span>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="section">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- if method_list -->
|
|
<div id="methods">
|
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
|
|
<div id="method-M000197" class="method-detail">
|
|
<a name="M000197"></a>
|
|
|
|
<div class="method-heading">
|
|
<a href="#M000197" class="method-signature">
|
|
<span class="method-name">def_method</span><span class="method-args">(object, method_name, filename=nil)</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
<p>
|
|
if object is an Class or Module then define instance method to it, else
|
|
define singleton method to it.
|
|
</p>
|
|
<p><a class="source-toggle" href="#"
|
|
onclick="toggleCode('M000197-source');return false;">[Source]</a></p>
|
|
<div class="method-source-code" id="M000197-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File erubis/evaluator.rb, line 79</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">def_method</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">method_name</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>)
|
|
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Module</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">:module_eval</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:instance_eval</span>
|
|
<span class="ruby-identifier">object</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">m</span>, <span class="ruby-node">"def #{method_name}; #{@src}; end"</span>, <span class="ruby-identifier">filename</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@filename</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'(erubis)'</span>)
|
|
<span class="ruby-keyword kw">end</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="method-M000196" class="method-detail">
|
|
<a name="M000196"></a>
|
|
|
|
<div class="method-heading">
|
|
<a href="#M000196" class="method-signature">
|
|
<span class="method-name">evaluate</span><span class="method-args">(_context=Context.new)</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
<p>
|
|
invoke context.instance_eval(@src)
|
|
</p>
|
|
<p><a class="source-toggle" href="#"
|
|
onclick="toggleCode('M000196-source');return false;">[Source]</a></p>
|
|
<div class="method-source-code" id="M000196-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File erubis/evaluator.rb, line 69</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">_context</span>=<span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>)
|
|
<span class="ruby-identifier">_context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">_context</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
|
<span class="ruby-comment cmt">#return _context.instance_eval(@src, @filename || '(erubis)')</span>
|
|
<span class="ruby-comment cmt">#@_proc ||= eval("proc { #{@src} }", Erubis::EMPTY_BINDING, @filename || '(erubis)')</span>
|
|
<span class="ruby-ivar">@_proc</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">eval</span>(<span class="ruby-node">"proc { #{@src} }"</span>, <span class="ruby-identifier">binding</span>(), <span class="ruby-ivar">@filename</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'(erubis)'</span>)
|
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-ivar">@_proc</span>)
|
|
<span class="ruby-keyword kw">end</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="method-M000195" class="method-detail">
|
|
<a name="M000195"></a>
|
|
|
|
<div class="method-heading">
|
|
<a href="#M000195" class="method-signature">
|
|
<span class="method-name">result</span><span class="method-args">(_binding_or_hash=TOPLEVEL_BINDING)</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
<p>
|
|
eval(@src) with binding object
|
|
</p>
|
|
<p><a class="source-toggle" href="#"
|
|
onclick="toggleCode('M000195-source');return false;">[Source]</a></p>
|
|
<div class="method-source-code" id="M000195-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File erubis/evaluator.rb, line 53</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">result</span>(<span class="ruby-identifier">_binding_or_hash</span>=<span class="ruby-constant">TOPLEVEL_BINDING</span>)
|
|
<span class="ruby-identifier">_arg</span> = <span class="ruby-identifier">_binding_or_hash</span>
|
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
|
<span class="ruby-identifier">_b</span> = <span class="ruby-identifier">binding</span>()
|
|
<span class="ruby-identifier">eval</span> <span class="ruby-identifier">_arg</span>.<span class="ruby-identifier">collect</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-node">"#{k} = _arg[#{k.inspect}]; "</span>}.<span class="ruby-identifier">join</span>, <span class="ruby-identifier">_b</span>
|
|
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">_arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Binding</span>)
|
|
<span class="ruby-identifier">_b</span> = <span class="ruby-identifier">_arg</span>
|
|
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">_arg</span>.<span class="ruby-identifier">nil?</span>
|
|
<span class="ruby-identifier">_b</span> = <span class="ruby-identifier">binding</span>()
|
|
<span class="ruby-keyword kw">else</span>
|
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self.class.name}#result(): argument should be Binding or Hash but passed #{_arg.class.name} object."</span>)
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">eval</span>(<span class="ruby-ivar">@src</span>, <span class="ruby-identifier">_b</span>, (<span class="ruby-ivar">@filename</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'(erubis'</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> |