# render\_to\_string in views

**URL:** <https://discuss.rubyonrails.org/t/render-to-string-in-views/19169>\
**Category:** rubyonrails-core\
**Created:** [October 11, 2007, 11:04pm UTC](https://discuss.rubyonrails.org/t/render-to-string-in-views/19169 "2007-10-11T23:04:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabe\_da\_Silveira1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gabe\_da\_Silveira1](https://discuss.rubyonrails.org/u/Gabe_da_Silveira1)\
**Post date:** [October 11, 2007, 11:04pm UTC](https://discuss.rubyonrails.org/t/render-to-string-in-views/19169/1 "2007-10-11T23:04:57Z")

</div>

I have a strong use case for render\_to\_string in views.

This is in the context of a facebook app, but I can imagine a lot of scenarios where this might occur:

Consider:

\<fb:request-form content="\<%= h render\_to\_string :partial =\> 'invite\_text' %\>"\>

The invite text is full of HTML that needs to have entities encoded so it can be stored in an attribute.

It seems to me this ought to be supported out of the box, but what do people think. Plugin?

---

<div class="post-metadata">

**Author:** ![Gabe\_da\_Silveira1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gabe\_da\_Silveira1](https://discuss.rubyonrails.org/u/Gabe_da_Silveira1)\
**Post date:** [October 11, 2007, 11:25pm UTC](https://discuss.rubyonrails.org/t/render-to-string-in-views/19169/2 "2007-10-11T23:25:24Z")

</div>

I just realized I can do:

helper\_method :render\_to\_string

Which is a fairly low pain threshold, but I still think it could just be default behavior.
