Module: SimpleNavigationBootstrap::BootstrapBase

Included in:
Bootstrap2, Bootstrap3
Defined in:
lib/simple_navigation_bootstrap/bootstrap_base.rb

Instance Method Summary collapse

Instance Method Details

#render(item_container) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simple_navigation_bootstrap/bootstrap_base.rb', line 6

def render(item_container)
  if skip_if_empty? && item_container.empty?
    ''
  else
    # Generate list of items
    list_content = with_bootstrap_configs do
      item_container.items.inject([]) do |list, item|
        list << render_item(self, item, item_container.level, bootstrap_version)
      end.join
    end

    # Set CSS class for container :
    #   class = 'nav' if level == 1
    #   class = 'dropdown-menu' if level > 1
    item_container.dom_class = [item_container.dom_class, container_class(item_container.level)].flatten.compact.join(' ')

    # Generate the final list
    (:ul, list_content, id: item_container.dom_id, class: item_container.dom_class)
  end
end