aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template_handlers
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-01-06 20:53:23 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-01-06 20:53:23 +0000
commita1b0349362fd6c17af5aeff481996f6fac235828 (patch)
treeacae9550ddae5e678618b9eb79ffc3bbf00b5c23 /actionpack/lib/action_view/template_handlers
parentca4c7ab362d0110bfade496ca66b30bafdb7f25e (diff)
downloadrails-a1b0349362fd6c17af5aeff481996f6fac235828.tar.gz
rails-a1b0349362fd6c17af5aeff481996f6fac235828.tar.bz2
rails-a1b0349362fd6c17af5aeff481996f6fac235828.zip
The asset_host block takes the controller request as an optional second argument. Example: use a single asset host for SSL requests. Closes #10549.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8578 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/template_handlers')
-rw-r--r--actionpack/lib/action_view/template_handlers/erb.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/template_handlers/erb.rb b/actionpack/lib/action_view/template_handlers/erb.rb
index 022fc362e7..87cb09952c 100644
--- a/actionpack/lib/action_view/template_handlers/erb.rb
+++ b/actionpack/lib/action_view/template_handlers/erb.rb
@@ -4,6 +4,15 @@ class ERB
module Util
HTML_ESCAPE = { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }
+ # A utility method for escaping HTML tag characters.
+ # This method is also aliased as <tt>h</tt>.
+ #
+ # In your ERb templates, use this method to escape any unsafe content. For example:
+ # <%=h @person.name %>
+ #
+ # ==== Example:
+ # puts html_escape("is a > 0 & a < 10?")
+ # # => is a &gt; 0 &amp; a &lt; 10?
def html_escape(s)
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
end