Permalink
Browse files

Adding RJS renderer for Rails 3.1

  • Loading branch information...
1 parent ed2495c commit 034287cc7495355017ba44f67f7d12e092a2da22 @MadRabbit committed Nov 9, 2011
Showing with 27 additions and 0 deletions.
  1. +1 −0 init.rb
  2. +26 −0 lib/rjs_renderer.rb
View
@@ -1,6 +1,7 @@
# Include hook code here
require 'right_rails'
+require 'rjs_renderer'
if defined?(Rails)
unless ::Rails.version < "3.1"
View
@@ -0,0 +1,26 @@
+#
+# RJS handler was kicked out of Rails 3.1 along with Prototype
+# so, here is a little substitute coz we use it here and there
+#
+module ActionView
+ module Template::Handlers
+ class RJS
+ # Default format used by RJS.
+ class_attribute :default_format
+ self.default_format = Mime::JS
+
+ def call(template)
+ "update_page do |page|;#{template.source}\nend"
+ end
+ end
+ end
+end
+
+ActiveSupport.on_load(:action_view) do
+ ActionView::Base.class_eval do
+ cattr_accessor :debug_rjs
+ self.debug_rjs = false
+ end
+
+ ActionView::Template.register_template_handler :rjs, ActionView::Template::Handlers::RJS.new
+end

0 comments on commit 034287c

Please sign in to comment.