I''m having some trouble updating my gem, poirot, to work properly with
Rails 3.1. Before Rails 3.1 I had a template handler that was
inheriting from ActionView::Template::Handler and including
ActionView::Template::Handlers::Compilable. This worked fine but in
Rails 3.1 I was getting deprecation warnings for using these.
I modified my handler so that it now just provides a call method and
have removed both ActionView::Template::Handlers::Compilable &
ActionView::Template::Handler. Rendering the templates seems to work
fine but I now have no access to the view context.
I need access to a view context because I''m rendering mustache
templates and what to be able to create a view object that exposes the
objects available in the view to the template, specifically any
instance variables set in the controller and any locals passed when
rendering a partial.
currently my code looks like this:
module Poirot
class Handler
attr_reader :template
def initialize(template)
@template = template
end
def self.call(template, *args)
self.new(template).call
end
def call
view_path = "#{template.virtual_path}_view"
abs_view_path = Rails.root.join(''app/views'',
view_path)
view_class = begin
view_path.classify.constantize
rescue NameError => e
Poirot::View
end
"#{view_class}.new(self,
''#{template.source.gsub(/''/, "\\\
\''")}'').render.html_safe"
end
end
end
Any help or advice would be greatly appreciated, thanks!
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.