<?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: ERB::Util</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">ERB::Util</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../../files/lib/action_view/erb/util_rb.html"> lib/action_view/erb/util.rb </a> <br /> </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000011">html_escape</a> <a href="#M000013">j</a> <a href="#M000012">json_escape</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">HTML_ESCAPE</td> <td>=</td> <td class="context-item-value">{ '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">JSON_ESCAPE</td> <td>=</td> <td class="context-item-value">{ '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }</td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000011" class="method-detail"> <a name="M000011"></a> <div class="method-heading"> <a href="Util.src/M000011.html" target="Code" class="method-signature" onclick="popupCode('Util.src/M000011.html');return false;"> <span class="method-name">html_escape</span><span class="method-args">(s)</span> </a> </div> <div class="method-description"> <p> A utility method for escaping HTML tag characters. This method is also aliased as <tt>h</tt>. </p> <p> In your ERb templates, use this method to escape any unsafe content. For example: </p> <pre> <%=h @person.name %> </pre> <h4>Example:</h4> <pre> puts html_escape("is a > 0 & a < 10?") # => is a &gt; 0 &amp; a &lt; 10? </pre> </div> </div> <div id="method-M000013" class="method-detail"> <a name="M000013"></a> <div class="method-heading"> <span class="method-name">j</span><span class="method-args">(s)</span> </div> <div class="method-description"> <p> Alias for <a href="Util.html#M000012">json_escape</a> </p> </div> </div> <div id="method-M000012" class="method-detail"> <a name="M000012"></a> <div class="method-heading"> <a href="Util.src/M000012.html" target="Code" class="method-signature" onclick="popupCode('Util.src/M000012.html');return false;"> <span class="method-name">json_escape</span><span class="method-args">(s)</span> </a> </div> <div class="method-description"> <p> A utility method for escaping HTML entities in JSON strings. This method is also aliased as <tt><a href="Util.html#M000013">j</a></tt>. </p> <p> In your ERb templates, use this method to escape any HTML entities: </p> <pre> <%=j @person.to_json %> </pre> <h4>Example:</h4> <pre> puts json_escape("is a > 0 & a < 10?") # => is a \u003E 0 \u0026 a \u003C 10? </pre> </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>