Accessing rails render method outside of view / Decorating render

G

Glenn Gillen

I'm developing a plugin for rails that ultimately needs to assign some
HTML to a javascript variable. In the interest of DRY, I want to be
able to basically specify a partial and pass in a collection and then
render the results. Because I'm assigning the output to a variable
though I need to catch it and escape things like single quotes. The
two options I can immediately see are:

1) Create a method similar to render in my own class. This would do
the required operations on my object and then delegate the processing
to render in ActionView. My problem is, how do I actually call the
render method from within my own class?

2) Decorate the existing render method to recognise if my new object
type is passed in and react accordingly. My problem is, how do I do
that exactly? And in such away that if another developer wanted to do
the same thing it would then wrap both of our render methods and not
just overwrite the others?

Make sense? Any insight greatly appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top