ERB::Util#html_escape creates fewer objects

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7513 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper
2007-09-18 11:56:04 +00:00
parent 8fd263cd4e
commit 2f60bb3327

View File

@@ -1,5 +1,15 @@
require 'erb'
class ERB
module Util
HTML_ESCAPE = { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }
def html_escape(s)
s.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] }
end
end
end
module ActionView #:nodoc:
class ActionViewError < StandardError #:nodoc:
end