title: Rendering html.erb templates in javascript
body: <p>I'm running rails 4.0.4. I have a form I'm using a partial in to add a subset of fields. The user has the option to remove those fields and replace them with other fields once they're on the page. I'd like to be able to add those fields back in in the event that they want to undo their decision. </p>
  
  <p>Render isn't available in javascript files (which seems odd for js.erb files). I've gotten as far as using the following to read the text of the file into a variable.</p>
  
  <pre><code>var master_quantity = "&lt;%= data='';File.open("#{Rails.root}/app/views/shared/_a2a_master_quantity.html.erb","r").each_line{|x| data+=x};data %&gt;";
  </code></pre>
  
  <p>Unfortunately escape_javascript doesn't appear to be available in the asests folder either, so I'm unable to use this string as it breaks the javascript.</p>
  
  <p>Anyone have any suggestions on cleaning the string or alternate methods to get the partial into my javascript?</p>