title: How to parse \n in string while passing the value to javascript
body: <p>In my code, i need to pass the value present in instance variable to javascript, and then use that value to set onto textarea.</p>
  
  <pre><code>$('textarea.myclass').val('&lt;%= @text_value %&gt;');
  </code></pre>
  
  <p>But if the variable <code>@text_value</code> contains <code>\n</code> (this is\n demo) then, its leads to javascript error and the page shows exactly as this, separated by space in between,</p>
  
  <pre><code>$('textarea.myclass').val('this is 
     // error message over here 
  demo');
  </code></pre>
  
  <p>Any way i can handle this ?</p>