Module: Opulent::Utils

Defined in:
lib/opulent/utils.rb

Constant Summary collapse

ESCAPE_HTML =

Used by escape_html

{
  '&'  => '&',
  '"'  => '"',
  '\'' => ''',
  '<'  => '&lt;',
  '>'  => '&gt;'
}.freeze
ESCAPE_HTML_PATTERN =

Pattern matching for html escape characters

Regexp.union(*ESCAPE_HTML.keys)
INTERPOLATION_PATTERN =

Ruby interpolation pattern

/(\#\{[^}]+\})/

Instance Method Summary collapse

Instance Method Details

#escape(html) ⇒ String

Returns an escaped copy of ‘html`.

Parameters:

  • html (String)

    The string to escape

Returns:

  • (String)

    The escaped string



28
29
30
# File 'lib/opulent/utils.rb', line 28

def escape(html)
  EscapeUtils.escape_html html.to_s.chomp, false
end