Module: Www::View

Included in:
Base
Defined in:
lib/www/view.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/www/view.rb', line 6

def self.included(base)
  base.send(:extend, ClassMethods)
end

Instance Method Details

#render(type, *args) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/www/view.rb', line 34

def render(type, *args)
  name = args[0].is_a?(String) ? args.shift : @route_name
  values = args[0]
  view_path = File.join(self.class.view_dir_path, "#{name}.#{type}")
  layout_path = "#{self.class.layout_path}.#{type}"

  if File.exists?(layout_path)
    Tilt.new(layout_path).render self, values do
      Tilt.new(view_path).render self, values
    end
  else
    Tilt.new(view_path).render self, values
  end
end