Reputation: 3426
I am using render_to_string
within a JSON 'render' response. The render_to_string
method seems to be striping my HTML, what am I doing wrong here?
Here's a sample:
render :json => {:html => render_to_string(:partial => 'view', :locals => { data => @data} )}
The response is coming through without any markup on it.
Upvotes: 0
Views: 2345
Reputation: 41
Have you tried setting the template format in the respond_to block like this:
format.json do
@template.template_format = :html
@html = render_to_string( :partial => 'view', :locals => { data => @data} )
render :json => { :success => true, :html => @html }
end
Upvotes: 4