Is there a way to render a html.erb partial as a one line of string?
I am trying to render a _foo.html.erb partial inside a javascript, such that I can use the whole html document as a string variable.
I have tried the following code:
var foo = "<%= render :partial => "foo" %>";
And inside _foo.html.erb, let's say I have the following:
<h1>Hello</h1>
<p>World</p>
This way will give me a syntax error in javascript because there is CRLF in the partial. But if I write code like...
<h1>Hello</h1>" +
"<p>World</p>
Now, it's not an error in javascript. I can do the latter way, but it is a disaster if the partial contains a lot of lines of code with ruby script.
Would there be any alternative way?
Thanks in advance.