Class: Vendors::SimpleNavigation::Renderer::TwitterSidenav

Inherits:
SimpleNavigation::Renderer::Base
  • Object
show all
Defined in:
lib/vendors/simple_navigation/renderer/twitter_sidenav.rb

Instance Method Summary collapse

Instance Method Details

#render(item_container) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vendors/simple_navigation/renderer/twitter_sidenav.rb', line 5

def render(item_container)
  content, first_item_selected = '', false
    
  item_container.items.each do |item|
    next if [
      I18n.t('general.edit'), I18n.t('general.destroy'), I18n.t('general.steps')
    ].include?(item.name)
    
    selected = item.selected? && item.method.blank?
    klass = selected && !first_item_selected ? 'active' : ''
    options = {}
    
    # only highlight on item
    first_item_selected = true if selected
    
    if item.method.present?
      options.merge!(method: item.method, confirm: I18n.t('general.questions.are_you_sure'))
    end
    
    content +=  :li, link_to(item.name, item.url, options), class: klass
  end
      
  ul =  :ul, content, class: 'nav nav-list'
      
   :div, ul, class: 'well sidebar-nav'
end