Module: Nesta::Navigation::Renderers
- Defined in:
- lib/nesta/navigation.rb
Instance Method Summary collapse
- #breadcrumb_ancestors ⇒ Object
- #breadcrumb_label(page) ⇒ Object
- #display_breadcrumbs(options = {}) ⇒ Object
- #display_menu(menu, options = {}) ⇒ Object
- #display_menu_item(item, options = {}) ⇒ Object
Instance Method Details
#breadcrumb_ancestors ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/nesta/navigation.rb', line 32 def ancestors = [] page = @page while page ancestors << page page = page.parent end ancestors.reverse end |
#breadcrumb_label(page) ⇒ Object
55 56 57 |
# File 'lib/nesta/navigation.rb', line 55 def (page) (page.abspath == '/') ? 'Home' : page.heading end |
#display_breadcrumbs(options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/nesta/navigation.rb', line 42 def ( = {}) haml_tag :ul, :class => [:class] do [0...-1].each do |page| haml_tag :li do haml_tag :a, :href => page.abspath do haml_concat (page) end end end haml_tag(:li) { haml_concat (@page) } end end |
#display_menu(menu, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nesta/navigation.rb', line 4 def (, = {}) defaults = { :class => nil, :levels => 2 } = defaults.merge() if [:levels] > 0 haml_tag :ul, :class => [:class] do .each do |item| (item, ) end end end end |
#display_menu_item(item, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nesta/navigation.rb', line 16 def (item, = {}) if item.respond_to?(:each) if ([:levels] - 1) > 0 haml_tag :li do (item, :levels => ([:levels] - 1)) end end else haml_tag :li do haml_tag :a, :<, :href => item.abspath do haml_concat item.heading end end end end |