Class: Ruhl::Plugin

Inherits:
ActionView::TemplateHandler
  • Object
show all
Defined in:
lib/ruhl/rails.rb

Instance Method Summary collapse

Constructor Details

#initialize(action_view) ⇒ Plugin



7
8
9
# File 'lib/ruhl/rails.rb', line 7

def initialize(action_view)
  @action_view = action_view
end

Instance Method Details

#render(template, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruhl/rails.rb', line 11

def render(template, options = {})
  layout = options[:layout]
  if layout
    layout_template = @action_view.controller.send(:find_layout, layout, 
                                                   @action_view.controller.send(:default_template_format) )
  else
    unless layout == false
      layout_template = @action_view.controller.active_layout
    end
  end

  if layout_template
    options[:layout]        = layout_template.filename 
    options[:layout_source] = layout_template.source
  end

  Ruhl::Engine.new(template.source, options).render(@action_view)
end