Module: YouthTree::Helpers::SidebarHelper

Defined in:
lib/youth_tree/helpers/sidebar_helper.rb

Instance Method Summary collapse

Instance Method Details

#default_sidebarObject

Renders a default sidebar



32
33
34
# File 'lib/youth_tree/helpers/sidebar_helper.rb', line 32

def default_sidebar
  render(:partial => 'shared/default_sidebar')
end

#has_sidebar?Boolean

Do we have a sidebar?

Returns:

  • (Boolean)


12
13
14
# File 'lib/youth_tree/helpers/sidebar_helper.rb', line 12

def has_sidebar?
  sidebar_content.present? && show_sidebar?
end

#main_content_classObject

Content class, inc. sidebar



22
23
24
# File 'lib/youth_tree/helpers/sidebar_helper.rb', line 22

def main_content_class
  (Array(@extra_content_classes) + [has_sidebar? ? "left" : "full-width"]).uniq.sort.join(" ")
end

#render_to_sidebar!(partial_name, options = {}) ⇒ Object

Render content for sidebar



27
28
29
# File 'lib/youth_tree/helpers/sidebar_helper.rb', line 27

def render_to_sidebar!(partial_name, options = {})
  sidebar_contains render(options.merge(:partial => partial_name))
end

Set sidebar content



17
18
19
# File 'lib/youth_tree/helpers/sidebar_helper.rb', line 17

def sidebar_contains(*args, &blk)
  content_for :sidebar, *args, &blk
end

Returns the sidebar content.



6
7
8
9
# File 'lib/youth_tree/helpers/sidebar_helper.rb', line 6

def sidebar_content
  content = content_for :sidebar
  content.present? ? content : default_sidebar
end