instance method
html_escape_once
Ruby on Rails 7.0.10
Since v4.0.13 PrivateSignature
html_escape_once(s)
A utility method for escaping HTML without affecting existing escaped entities.
html_escape_once('1 < 2 & 3') # => "1 < 2 & 3" html_escape_once('<< Accept & Checkout') # => "<< Accept & Checkout"
Parameters
-
sreq
Source
# File activesupport/lib/active_support/core_ext/string/output_safety.rb, line 58
def html_escape_once(s)
result = ActiveSupport::Multibyte::Unicode.tidy_bytes(s.to_s).gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE)
s.html_safe? ? result.html_safe : result
end
Defined in activesupport/lib/active_support/core_ext/string/output_safety.rb line 58
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ERB::Util