Class: ReeText::EscapeJavascript

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_text/package/ree_text/functions/escape_javascript.rb

Instance Method Summary collapse

Instance Method Details

#call(javascript) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/ree_lib/packages/ree_text/package/ree_text/functions/escape_javascript.rb', line 13

def call(javascript)
  javascript = javascript.to_s

  if is_blank(javascript)
    ""
  else
    javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP)
  end
end