module Haml::Helpers

def html_escape(text)

Returns:
  • (String) - The sanitized string

Parameters:
  • text (String) -- The string to sanitize
def html_escape(text)
  pattern = '[\"><&]'
  regex = if RUBY_VERSION >= '1.9'
    Regexp.new(pattern.force_encoding(text.encoding), Regexp::FIXEDENCODING)
  else
    Regexp.new(pattern)
  end
  text.to_s.gsub(regex) {|s| HTML_ESCAPE[s]}
end