Skip to content

Commit

Permalink
Template registration waits for :action_view load.
Browse files Browse the repository at this point in the history
  • Loading branch information
forrest committed Feb 26, 2012
1 parent c591c5c commit c6f5156
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/prawnto/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ class Railtie < Rails::Railtie
# Register the MimeType and the two template handlers.
initializer "prawnto.register_handlers" do
Mime::Type.register("application/pdf", :pdf) unless Mime::Type.lookup_by_extension(:pdf)
ActionView::Template.register_template_handler 'prawn', Prawnto::TemplateHandlers::Base
ActionView::Template.register_template_handler 'prawn_dsl', Prawnto::TemplateHandlers::Base # for legacy systems

ActiveSupport.on_load(:action_view) do
ActionView::Template.register_template_handler :prawn, Prawnto::TemplateHandlers::Base
ActionView::Template.register_template_handler :prawn_dsl, Prawnto::TemplateHandlers::Base # for legacy systems
end
end

# This will run it once in production and before each load in development.
# Include the mixins for ActionController and ActionView.
config.to_prepare do
ActionController::Base.send :include, Prawnto::ActionControllerMixin
ActionMailer::Base.send :include, Prawnto::ActionControllerMixin
ActionView::Base.send :include, Prawnto::ActionViewMixin
end

end
end
end

0 comments on commit c6f5156

Please sign in to comment.