mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Call String#gsub with Hash directly
This commit is contained in:
parent
5807513048
commit
cc986db546
1 changed files with 2 additions and 2 deletions
|
@ -42,7 +42,7 @@ class ERB
|
|||
# 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 @@ class ERB
|
|||
# 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
|
||||
|
||||
|
|
Loading…
Reference in a new issue