Module: Nesta::Navigation::Renderers
- Defined in:
- lib/nesta/navigation.rb
Instance Method Summary (collapse)
- - (Object) breadcrumb_ancestors
- - (Object) breadcrumb_label(page)
- - (Object) current_breadcrumb_class
- - (Boolean) current_item?(item)
- - (Object) current_menu_item_class
- - (Object) display_breadcrumbs(options = {})
- - (Object) display_menu(menu, options = {})
- - (Object) display_menu_item(item, options = {})
- - (Object) link_text(page)
Instance Method Details
- (Object) breadcrumb_ancestors
33 34 35 36 37 38 39 40 41 |
# File 'lib/nesta/navigation.rb', line 33 def ancestors = [] page = @page while page ancestors << page page = page.parent end ancestors.reverse end |
- (Object) breadcrumb_label(page)
67 68 69 70 |
# File 'lib/nesta/navigation.rb', line 67 def (page) Nesta.deprecated('breadcrumb_label', 'use link_text') link_text(page) end |
- (Object) current_breadcrumb_class
80 81 82 |
# File 'lib/nesta/navigation.rb', line 80 def nil end |
- (Boolean) current_item?(item)
72 73 74 |
# File 'lib/nesta/navigation.rb', line 72 def current_item?(item) request.path == item.abspath end |
- (Object) current_menu_item_class
76 77 78 |
# File 'lib/nesta/navigation.rb', line 76 def 'current' end |
- (Object) display_breadcrumbs(options = {})
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nesta/navigation.rb', line 43 def ( = {}) haml_tag :ul, :class => [:class] do [0...-1].each do |page| haml_tag :li do haml_tag :a, :<, :href => path_to(page.abspath), :itemprop => 'url' do haml_tag :span, :<, :itemprop => 'title' do haml_concat link_text(page) end end end end haml_tag(:li, :class => ) do haml_concat link_text(@page) end end end |
- (Object) display_menu(menu, options = {})
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 |
- (Object) display_menu_item(item, options = {})
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 html_class = current_item?(item) ? : nil haml_tag :li, :class => html_class do haml_tag :a, :<, :href => path_to(item.abspath) do haml_concat link_text(item) end end end end |
- (Object) link_text(page)
60 61 62 63 64 65 |
# File 'lib/nesta/navigation.rb', line 60 def link_text(page) page.link_text rescue LinkTextNotSet return 'Home' if page.abspath == '/' raise end |