Module: SimpleNavigation::Helper
- Defined in:
- lib/simple_navigation.rb
Overview
Simple Navigation helper methods module
Instance Attribute Summary collapse
-
#current_menu_id ⇒ Object
Returns the value of attribute current_menu_id.
-
#custom_titles ⇒ Object
Returns the value of attribute custom_titles.
Instance Method Summary collapse
-
#simple_navigation(name, options = {}) ⇒ Object
Renders simple navigation menu by key name.
Instance Attribute Details
#current_menu_id ⇒ Object
Returns the value of attribute current_menu_id.
6 7 8 |
# File 'lib/simple_navigation.rb', line 6 def @current_menu_id end |
#custom_titles ⇒ Object
Returns the value of attribute custom_titles.
6 7 8 |
# File 'lib/simple_navigation.rb', line 6 def custom_titles @custom_titles end |
Instance Method Details
#simple_navigation(name, options = {}) ⇒ Object
Renders simple navigation menu by key name
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simple_navigation.rb', line 9 def (name, = {}) # Load navigation hash = SimpleNavigation::Builder.[name.to_sym] # Reset current menu self. = nil settings = { :id => [:id], :class => [:class] || 'simple_navigation', } self.custom_titles = [:custom_titles] || {} # Set CSS class that user may added if .has_key?(:options) && [:options].has_key?(:class) settings[:class] << " #{[:options][:class]}" end # Render root menus if .has_key?(:menus) && ![:menus].empty? = [:menus].enum_with_index.collect do |item, index| = { :class => item[:options][:class].clone || '' } [:class] << ' first' if index == 0 [:class] << ' last' if index == [:menus].size - 1 (item, ) end end content_tag(:ul, || '', settings) end |