public Method

JavaScriptHelper.escape_javascript(javascript)

Escape carrier returns and single and double quotes for JavaScript segments.

Source Code

# File action_view/helpers/javascript_helper.rb, line 151
def escape_javascript(javascript)
  (javascript || '').gsub('\\','\0\0').gsub('</','<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.