Module: BreadcrumbsHelper
- Defined in:
- app/helpers/breadcrumbs_helper.rb
Instance Method Summary collapse
- #breadcrumb_lis_for_breadcrumb_hashes(breadcrumbs) ⇒ Object
-
#breadcrumb_ul ⇒ Object
This returns the html code for an unordered list containing the bread crumb elements.
- #breadcrumb_ul_for_navable(navable) ⇒ Object
- #breadcrumb_ul_for_navables(navables = []) ⇒ Object
- #cached_breadcrumb_ul ⇒ Object
- #cached_breadcrumb_ul_for_navable(navable) ⇒ Object
Instance Method Details
#breadcrumb_lis_for_breadcrumb_hashes(breadcrumbs) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/breadcrumbs_helper.rb', line 36 def ( ) .collect do || css_class = "crumb" css_class = "root crumb" if == .first css_class = "last crumb" if == .last css_class += " slim" if [ :slim ] c = content_tag :li, :class => css_class do # Do not use turbolinks for external links, since they are directed by the PagesController. # The redirect to external sites causes a 'forbidden' error when using turbolinks. # if [:navable].kind_of?(Page) && [:navable].redirect_to.kind_of?(String) = {'data-no-turbolink' => true} else = {} end link_to [ :title ], [ :navable ], end unless == .last c+= content_tag :li, " ".html_safe, :class => "crumb sep" end c end.join.html_safe end |
#breadcrumb_ul ⇒ Object
This returns the html code for an unordered list containing the bread crumb elements.
7 8 9 |
# File 'app/helpers/breadcrumbs_helper.rb', line 7 def end |
#breadcrumb_ul_for_navable(navable) ⇒ Object
20 21 22 23 24 25 |
# File 'app/helpers/breadcrumbs_helper.rb', line 20 def ( navable ) content_tag :ul do = navable.nav_node. # => [ { title: 'foo', navable: ... }, ... ] ( ) end end |
#breadcrumb_ul_for_navables(navables = []) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/helpers/breadcrumbs_helper.rb', line 27 def ( navables = [] ) = navables.collect do |navable| = { title: navable.title, navable: navable } end content_tag :ul do ( ) end end |
#cached_breadcrumb_ul ⇒ Object
11 12 13 14 |
# File 'app/helpers/breadcrumbs_helper.rb', line 11 def return @navable if @navable return @navables if @navables end |
#cached_breadcrumb_ul_for_navable(navable) ⇒ Object
16 17 18 |
# File 'app/helpers/breadcrumbs_helper.rb', line 16 def (navable) Rails.cache.fetch([navable, 'breadcrumb_ul_for_navable', navable.ancestors_cache_key]) { (navable) } end |