Search code examples
ruby-on-railsescapinghaml

Why doesn't the shorthand escape_javascript actually work?


Here's my biopsis

Works :

:plain
  console.log("#{escape_javascript(render(@job_charge).html_safe)}");

Does not work ( but should? ) :

:plain
  console.log("#{j render(@job_charge).html_safe }");

Solution

  • It looks like j is actually shorthand for json_escape, not escape_javascript.

    http://api.rubyonrails.org/classes/ERB/Util.html