Module: SidebarHelper

Defined in:
lib/sidebar_helper.rb

Instance Method Summary collapse

Instance Method Details

#content_hashObject

get controller instance variables



34
35
36
37
38
39
40
# File 'lib/sidebar_helper.rb', line 34

def content_hash
  hash = {}
  controller.instance_variables.grep(/@[a-zA-Z]/).map do |var|
    hash[var.to_s] = controller.instance_variable_get(var)
  end
  hash
end

#render_scene_sidebars(scene) ⇒ Object

render scene sidebars

params:
  +scene+       scene name


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sidebar_helper.rb', line 5

def render_scene_sidebars(scene)
  scene_htmls = []
  begin
    @scene = SceneSidebar.parse_scene(scene)
    if @scene
      @scene.sidebars.each do |sb|
        scene_htmls << render_sidebar(sb)
      end
    end
  end
  scene_htmls.join.html_safe
end

#render_sidebar(sidebar, current_user = controller.current_user, options = {}) ⇒ Object

render_sidebar

params:
   +sidebar+                Sidebar instance or sidebar name
   +current_user+       sidebar of current_user, default controller.current_user 
   +options+                optional parameters


23
24
25
26
27
28
29
30
31
# File 'lib/sidebar_helper.rb', line 23

def render_sidebar(sidebar,current_user=controller.current_user,options={})
  sidebar = sidebar.is_a?(Sidebar) ? sidebar : Sidebar.parse_sidebar(sidebar)
  if sidebar
    sidebar.parse_request(params,content_hash,current_user)
    render_to_string(:partial => sidebar.content_partial,
                   :locals => sidebar.to_locals_hash,
                   :layout => false).html_safe
  end
end