module SidebarHelper

Public Instance Methods

content_hash() click to toggle source

get controller instance variables

# 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) click to toggle source

render scene sidebars

params:
  +scene+       scene name
# 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={}) click to toggle source

render_sidebar

params:
   +sidebar+                Sidebar instance or sidebar name
   +current_user+       sidebar of current_user, default controller.current_user 
   +options+                optional parameters
# 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