Rails How to escape and display the contents of a rendered view
html, ruby, ruby-on-rails, ruby-on-rails-3, view
Solution
Did you try using
<%= CGI.escapeHTML render('partial') %>
Problem
I am trying to show a rails view file in a textarea. the view file contains a bunch of HTML, which I want to escape so that it does not interfere with on page html. here is an example: ``` In this view we are going to display the contents of a partial <textarea> <%= html_escape render('partial') %> </textarea> ``` and in partial.html.erb I would have ``` Hello this is partial.html.erb and this is a <textarea>textarea</textarea> blah blah blah. ``` The problem is: the textarea in partial.html is breaking the textarea in the first view because it is not being html_escaped. How do I property escape and display the contents of the partial inside the textarea?