Module: Pancake::Mixins::Render::ViewContext::Renderer

Included in:
Pancake::Mixins::Render::ViewContext
Defined in:
lib/pancake/mixins/render/render.rb

Instance Method Summary collapse

Instance Method Details

#_current_rendererObject



72
73
74
# File 'lib/pancake/mixins/render/render.rb', line 72

def _current_renderer
  @_current_renderer
end

#_with_renderer(renderer) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/pancake/mixins/render/render.rb', line 64

def _with_renderer(renderer)
  orig_renderer = @_current_renderer
  @_current_renderer = renderer
  result = yield
  @_current_renderer = orig_renderer
  result
end

#partial(*args) ⇒ Object



60
61
62
# File 'lib/pancake/mixins/render/render.rb', line 60

def partial(*args)
  _view_context_for.partial(*args)
end

#render(template, opts = {}, &blk) ⇒ Object

Raises:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pancake/mixins/render/render.rb', line 43

def render(template, opts = {}, &blk)
  template = _view_context_for.template(template)
  raise TemplateNotFound unless template
  result = _with_renderer template do
    _current_renderer.render(self, opts, &blk) # only include the block once
  end

  if @_inherit_helper.inherits_from
    next_template = _view_context_for.template(@_inherit_helper.inherits_from)
    @_inherit_helper.inherits_from = nil
    result = _with_renderer next_template do
      _current_renderer.render(self,opts)
    end
  end
  result
end