Class: Grass::Render::View

Inherits:
Object
  • Object
show all
Includes:
Renderer
Defined in:
lib/grass/render/view.rb

Constant Summary collapse

DEFAULT_LAYOUT =
"application"
DEFAULT_VIEW =
"show"

Instance Method Summary collapse

Methods included from Renderer

#initialize, #templates

Methods included from Helpers::RenderHelper

#include_partial, #render_content, #render_partial

Instance Method Details

#layoutObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/grass/render/view.rb', line 21

def layout
  @layout ||= begin
    keys = ["/views/layouts/#{DEFAULT_LAYOUT}"]
    unless @data[:source].nil?
      keys.unshift "/views/layouts/#{@data[:source].dir}/#{@data[:source].path}",
      "/views/layouts/#{@data[:source].dir}/#{DEFAULT_VIEW}"
    end
    Source[keys].first
  end
end

#renderObject



12
13
14
15
16
17
18
19
# File 'lib/grass/render/view.rb', line 12

def render    
  if @data[:layout].nil? && !self.layout.nil?
    @data[:layout] = @layout
    templates.last.new{ @layout.raw }.render(self,@data) { super }
  else
    super
  end
end