Class: OMF::Web::Theme::TwoColumnsRenderer

Inherits:
LayoutRenderer
  • Object
show all
Defined in:
lib/omf-web/theme/bright/two_columns_renderer.rb

Constant Summary collapse

DEFAULT_LAYOUT =
'66_33'
@@layout2class =
{
  '50_50' => "yui-g",
  '66_33' => "yui-gc",
  '33_66' => "yui-gd",
  '75_25' => "yui-ge",
  '25_75' => "yui-gf"
}

Instance Method Summary collapse

Methods inherited from LayoutRenderer

#render?

Constructor Details

#initialize(lwidgets, rwidgets, opts) ⇒ TwoColumnsRenderer

Returns a new instance of TwoColumnsRenderer.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/omf-web/theme/bright/two_columns_renderer.rb', line 17

def initialize(lwidgets, rwidgets, opts)
  super opts
  # looking for something like: 'layout/two_columns/50_50'
  layout = (opts[:type].split('/')[2] || DEFAULT_LAYOUT).to_s
  unless @layout_class = @@layout2class[layout]
    warn "Unknown layout '#{layout}'"
    @layout_class = @@layout2class[DEFAULT_LAYOUT]
  end
  
  @lwidgets = lwidgets || []
  @rwidgets = rwidgets || []
  @opts = opts
end

Instance Method Details

#contentObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/omf-web/theme/bright/two_columns_renderer.rb', line 31

def content

  div :class => @layout_class do
    div :class => "yui-u first column column-left" do
      render_left
    end
    div :class => "yui-u column column-right" do
      render_right
    end
  end
end

#render_leftObject



43
44
45
46
47
# File 'lib/omf-web/theme/bright/two_columns_renderer.rb', line 43

def render_left
  @lwidgets.each do |w|
    render_widget w
  end
end

#render_rightObject



49
50
51
52
53
# File 'lib/omf-web/theme/bright/two_columns_renderer.rb', line 49

def render_right
  @rwidgets.each do |w|
    render_widget w
  end
end

#render_widget(w) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/omf-web/theme/bright/two_columns_renderer.rb', line 55

def render_widget(w)
  r = w.content
  unless w.layout?
    r = WidgetChrome.new(w, r, @opts)
  end
  rawtext r.to_html      
end