Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9554 from tmm1/string-gsub-hash

Use 1.9 String#gsub syntax
  • Loading branch information...
commit 40936da37222f3a669505b8e428062c4118ca30e 2 parents 5807513 + cc986db
@josevalim josevalim authored
View
4 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -42,7 +42,7 @@ def html_escape(s)
# html_escape_once('<< Accept & Checkout')
# # => "<< Accept & Checkout"
def html_escape_once(s)
- result = s.to_s.gsub(HTML_ESCAPE_ONCE_REGEXP) { |special| HTML_ESCAPE[special] }
+ result = s.to_s.gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE)
s.html_safe? ? result.html_safe : result
end
@@ -60,7 +60,7 @@ def html_escape_once(s)
# json_escape('{"name":"john","created_at":"2010-04-28T01:39:31Z","id":1}')
# # => {name:john,created_at:2010-04-28T01:39:31Z,id:1}
def json_escape(s)
- result = s.to_s.gsub(JSON_ESCAPE_REGEXP) { |special| JSON_ESCAPE[special] }
+ result = s.to_s.gsub(JSON_ESCAPE_REGEXP, JSON_ESCAPE)
s.html_safe? ? result.html_safe : result
end
Please sign in to comment.
Something went wrong with that request. Please try again.