Last active
May 27, 2021 23:30
-
-
Save steveclarke/ef39f3f0fa8f28ca01e28111a3a64880 to your computer and use it in GitHub Desktop.
Revisions
-
steveclarke renamed this gist
May 27, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
steveclarke created this gist
May 27, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ Custom Builder for [Breadcrumbs on Rails](https://github.com/weppos/breadcrumbs_on_rails) with Bootstrap 5: ```ruby # app/lib/bootstrap_five_breadcrumbs.rb class BootstrapFiveBreadcrumbs < BreadcrumbsOnRails::Breadcrumbs::SimpleBuilder def render return '' if @elements.size == 0 @options[:outer_tag] ||= :ol @options[:tag] ||= :li @options[:separator] ||= "" @context.content_tag(@options[:outer_tag], class: 'breadcrumb') do @elements.collect do |element| render_element(element) end.join(@options[:separator]).html_safe end end def render_element(element) if element.path == nil content = compute_name(element) else content = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options) end if @elements.last == element @context.content_tag(@options[:tag], content, class: "breadcrumb-item active", "aria-current": "page") else @context.content_tag(@options[:tag], content, class: "breadcrumb-item") end end end ``` ```erb # _breadcrumbs.html.erb <nav aria-label="breadcrumb"> <%= render_breadcrumbs builder: ::BootstrapFiveBreadcrumbs %> </nav> ```