Module: HomePage::LayoutHelper

Defined in:
app/helpers/home_page/layout_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/home_page/layout_helper.rb', line 3

def breadcrumbs
  result = render_navigation context: application_navigation, renderer: :breadcrumbs_without_method_links, join_with: ' > '
  result = result && result.scan('<a').length > 1 ? result : ''
  
  if respond_to?(:resource) && resource.respond_to?(:ancestors)
    breadcrumbs_with_ancestors(result)
  else
    result
  end
end


14
15
16
17
18
19
20
# File 'app/helpers/home_page/layout_helper.rb', line 14

def breadcrumbs_with_ancestors(links)
  links = links.split(' &gt; ')
  current_resource_link = links.pop
  links += resource.ancestors.map {|ancestor| link_to ancestor.name, ancestor }
  links << current_resource_link
  raw links.join(' &gt; ')    
end

#sidenav(links_count = 2) ⇒ Object



22
23
24
25
26
27
# File 'app/helpers/home_page/layout_helper.rb', line 22

def sidenav(links_count = 2)
  links_count ||= 2
  result = render_navigation context: application_navigation, renderer: :twitter_sidenav, level: @twitter_sidenav_level
  
  result && result.scan('<a').length >= links_count ? result : ''
end