Is there a way to render the html.erb part as one line of a line?
I am trying to make the _foo.html.erb part inside javascript so that I can use the whole html document as a string variable.
I 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 method will give me a syntax error in javascript, because in partial there is CRLF. But if I write code like ...
<h1>Hello</h1>" + "<p>World</p>
Now this is not a bug in javascript. I can do the latter way, but it is a disaster if the partial contains many lines of code with a ruby ββscript.
Will there be an alternative way?
Thanks in advance.
javascript ruby-on-rails-3 partial render
Dynamicscope
source share