Skip to content
This repository
tree: e6de95889d
Fetching contributors…

Cannot retrieve contributors at this time

file 29 lines (26 sloc) 0.714 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
module ActionView
  module TemplateHandlers
    class RJS < TemplateHandler
      def self.line_offset
        2
      end

      def compile(template)
        "controller.response.content_type ||= Mime::JS\n" +
        "update_page do |page|\n#{template}\nend"
      end

      def self.compilable?
        true
      end

      def cache_fragment(block, name = {}, options = nil) #:nodoc:
        @view.fragment_for(block, name, options) do
          begin
            debug_mode, ActionView::Base.debug_rjs = ActionView::Base.debug_rjs, false
            eval('page.to_s', block.binding)
          ensure
            ActionView::Base.debug_rjs = debug_mode
          end
        end
      end
    end
  end
end
Something went wrong with that request. Please try again.