I am trying to add a template type to render FlexImage::Model objects. I seem to be missing some understanding on how rails handles some of the details around this. The template is pure ruby code, it just has some special handling around the template to further process the returned value of the template. The biggest issue is that I can''t figure out how to get the view aware of the helpers and instance variables from the controller. Currently, I am simply doing something like this: result = action_view.controller.instance_eval(@flexi_template) This allows me access to the instance variable from the controllers, but not the helpers. So what is proper way to implement a template handler so that it gets all the treatments that a view should. Meaning it gets the helpers and instance variables that one would expect from the rhtml views. I have studied some other plugins like markaby and the rails code itself and can''t seem to get my head around this. Also the rails docs regarding this are quite brief. The full code for my Template handler is here: http://pastie.caboo.se/29106 Any insight would be appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> Any insight would be appreciated.While I am at it, if anyone has any idea why ActionController::Base.exempt_from_layout :foo doesn''t work, it would help to get rid of the render statement from the controller: def image @image = MyImage.find(1) render :layout => false # required cause exempt_from_layout is broken end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> Alex Wayne wrote: >> Any insight would be appreciated. > > While I am at it, if anyone has any idea why > > ActionController::Base.exempt_from_layout :foo > > doesn''t work, it would help to get rid of the render statement from the > controller: > > def image > @image = MyImage.find(1) > render :layout => false # required cause exempt_from_layout is > broken > endDon''t you love when you struggle with something for a long time, then you get frustrated and voice a question about it to others. Then, as if by magic, the universe answers your public outcry for assistance and grants the knowledge you were looking for. I stumbled upon the MarkDownOnRails plugin http://rubygreenblue.com/blog/article/markdown_template_handler_for_rails, which has exactly the simple and easy to understand template handling that I needed to figure this out. Turns out that rails passes you a view object which *mostly* has what you need. Here is the template handler, rewritten, and seems to work properly, for all that are curious: http://pastie.caboo.se/29137 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---