Class: ActionView::TemplateHandlers::RJS

Inherits:
ActionView::TemplateHandler show all
Includes:
Compilable
Defined in:
lib/action_view/template_handlers/rjs.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Compilable

#compile_template, included, #render

Methods inherited from ActionView::TemplateHandler

compilable?, #compilable?, #initialize, #line_offset, #render

Constructor Details

This class inherits a constructor from ActionView::TemplateHandler

Class Method Details

.line_offsetObject



6
7
8
# File 'lib/action_view/template_handlers/rjs.rb', line 6

def self.line_offset
  2
end

Instance Method Details

#cache_fragment(block, name = {}, options = nil) ⇒ Object

:nodoc:



15
16
17
18
19
20
21
22
23
24
# File 'lib/action_view/template_handlers/rjs.rb', line 15

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

#compile(template) ⇒ Object



10
11
12
13
# File 'lib/action_view/template_handlers/rjs.rb', line 10

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