Module: Mack::ViewHelpers::StringHelpers

Included in:
JavaScript::Selector
Defined in:
lib/mack-javascript/view_helpers/string_helpers.rb

Instance Method Summary collapse

Instance Method Details

#escape_javascript(javascript) ⇒ Object

Escapes Javascript



7
8
9
# File 'lib/mack-javascript/view_helpers/string_helpers.rb', line 7

def escape_javascript(javascript)
  (javascript || '').gsub('\\','\0\0').gsub('</','<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end