Module: ActiveSupport::CoreExt::ERBUtil

Included in:
ERBUtilPrivate, ERB::Util
Defined in:
lib/active_support/core_ext/erb/util.rb

Instance Method Summary collapse

Instance Method Details

#html_escape(s) ⇒ Object Also known as: h

A utility method for escaping HTML tag characters. This method is also aliased as h.

puts html_escape('is a > 0 & a < 10?')
# => is a &gt; 0 &amp; a &lt; 10?


10
11
12
13
14
15
16
17
# File 'lib/active_support/core_ext/erb/util.rb', line 10

def html_escape(s) # :nodoc:
  s = s.to_s
  if s.html_safe?
    s
  else
    super(ActiveSupport::Multibyte::Unicode.tidy_bytes(s))
  end
end

#unwrapped_html_escapeObject

HTML escapes strings but doesn’t wrap them with an ActiveSupport::SafeBuffer. This method is not for public consumption! Seriously! :nodoc:



18
19
20
21
22
23
24
25
# File 'lib/active_support/core_ext/erb/util.rb', line 18

def html_escape(s) # :nodoc:
  s = s.to_s
  if s.html_safe?
    s
  else
    super(ActiveSupport::Multibyte::Unicode.tidy_bytes(s))
  end
end