Hi, everyone.
In my rails application my models have a to_html method. This method is called in one of the views so the model's attributes can be displayed properly regardless of their classes (because all of my classes implement that method)
That is a neat solution, but one thing bugs me. I need to write this html code inside the double quotes (as strings) and eventually escape the other double quotes that I use in my html code manually.
I'd like to be able to work with rhtml files instead: read them, evaluate the eventual ruby code in it and return the result as a string with the necessary escaped characters. I'll give you an example:
The following code:
<label for="blabla"> <%= ruby_variable.name %> </label>
when processed should return me:
"<label for=\"blabla\"> name </label>"
Does anyone know something that already does that or could point me in the good direction? I was thinking of writing a piece of code that does that myself. But if something is already out there working, I'd me happy to use it.
Thanks