D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
td-agent
/
embedded
/
lib
/
ruby
/
gems
/
2.1.0
/
gems
/
erubis-2.7.0
/
doc-api
/
classes
/
Erubis
/
Filename :
XmlHelper.html
back
Copy
<?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::XmlHelper</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::XmlHelper</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../../files/erubis/helper_rb.html"> erubis/helper.rb </a> <br /> </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <p> helper for xml </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000106">escape_xml</a> <a href="#M000107">escape_xml2</a> <a href="#M000108">h</a> <a href="#M000109">html_escape</a> <a href="#M000111">u</a> <a href="#M000110">url_encode</a> </div> </div> </div> <!-- if includes --> <div id="section"> <div id="constants-list"> <h3 class="section-bar">Constants</h3> <div class="name-list"> <table summary="Constants"> <tr class="top-aligned-row context-row"> <td class="context-item-name">ESCAPE_TABLE</td> <td>=</td> <td class="context-item-value">{ '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', "'" => '&#039;', }</td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000106" class="method-detail"> <a name="M000106"></a> <div class="method-heading"> <a href="#M000106" class="method-signature"> <span class="method-name">escape_xml</span><span class="method-args">(value)</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000106-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000106-source"> <pre> <span class="ruby-comment cmt"># File erubis/helper.rb, line 24</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_xml</span>(<span class="ruby-identifier">value</span>) <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> <span class="ruby-comment cmt">#value.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] }</span> <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000107" class="method-detail"> <a name="M000107"></a> <div class="method-heading"> <a href="#M000107" class="method-signature"> <span class="method-name">escape_xml2</span><span class="method-args">(value)</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000107-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000107-source"> <pre> <span class="ruby-comment cmt"># File erubis/helper.rb, line 29</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_xml2</span>(<span class="ruby-identifier">value</span>) <span class="ruby-keyword kw">return</span> <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-value str">'&amp;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/</</span>,<span class="ruby-value str">'&lt;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/>/</span>,<span class="ruby-value str">'&gt;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/"/</span>,<span class="ruby-value str">'&quot;'</span>) <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000108" class="method-detail"> <a name="M000108"></a> <div class="method-heading"> <span class="method-name">h</span><span class="method-args">(value)</span> </div> <div class="method-description"> <p> Alias for <a href="XmlHelper.html#M000106">escape_xml</a> </p> </div> </div> <div id="method-M000109" class="method-detail"> <a name="M000109"></a> <div class="method-heading"> <span class="method-name">html_escape</span><span class="method-args">(value)</span> </div> <div class="method-description"> <p> Alias for <a href="XmlHelper.html#M000106">escape_xml</a> </p> </div> </div> <div id="method-M000111" class="method-detail"> <a name="M000111"></a> <div class="method-heading"> <span class="method-name">u</span><span class="method-args">(str)</span> </div> <div class="method-description"> <p> Alias for <a href="XmlHelper.html#M000110">url_encode</a> </p> </div> </div> <div id="method-M000110" class="method-detail"> <a name="M000110"></a> <div class="method-heading"> <a href="#M000110" class="method-signature"> <span class="method-name">url_encode</span><span class="method-args">(str)</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000110-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000110-source"> <pre> <span class="ruby-comment cmt"># File erubis/helper.rb, line 36</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">url_encode</span>(<span class="ruby-identifier">str</span>) <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[^-_.a-zA-Z0-9]+/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'C*'</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-value str">"%%%02X"</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">i</span> }.<span class="ruby-identifier">join</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>