Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. @mrfoto mrfoto revised this gist Sep 30, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@
    #
    class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
    def render
    @context.content_tag(:ol, class: 'breadcrumb') do
    return '' if @elements.empty?
    @context.content_tag :ol, class: 'breadcrumb' do
    @elements.collect do |element|
    render_element element
    end.join("\n").html_safe
  2. @mrfoto mrfoto revised this gist Sep 30, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -14,9 +14,9 @@ def render
    end

    def render_element element
    current = @context.current_page?(compute_path(element))
    @context.content_tag(:li, class: ('active' if current)) do
    @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    current = @context.current_page? compute_path(element)
    @context.content_tag :li, class: ('active' if current) do
    @context.link_to_unless_current compute_name(element), compute_path(element), element.options
    end
    end
    end
  3. @mrfoto mrfoto revised this gist Sep 30, 2013. 1 changed file with 2 additions and 8 deletions.
    10 changes: 2 additions & 8 deletions bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,5 @@
    # The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
    # It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
    #
    # BootstrapBreadcrumbsBuilder accepts a limited set of options:
    # * separator: what should be displayed as a separator between elements
    #
    # You can use it with the :builder option on render_breadcrumbs:
    # <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder%>
    # <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder %>
    #
    # Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
    # config.autoload_paths += Dir["#{config.root}/lib/"]
    @@ -25,4 +19,4 @@ def render_element element
    @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    end
    end
    end
    end
  4. @mrfoto mrfoto revised this gist Sep 30, 2013. 1 changed file with 7 additions and 11 deletions.
    18 changes: 7 additions & 11 deletions bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -5,28 +5,24 @@
    # * separator: what should be displayed as a separator between elements
    #
    # You can use it with the :builder option on render_breadcrumbs:
    # <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
    # <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder%>
    #
    # Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
    # config.autoload_paths += Dir["#{config.root}/lib/"]
    #
    class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
    def render
    @context.content_tag(:ul, class: 'breadcrumb') do
    @context.content_tag(:ol, class: 'breadcrumb') do
    @elements.collect do |element|
    render_element(element)
    end.join.html_safe
    render_element element
    end.join("\n").html_safe
    end
    end

    def render_element(element)
    def render_element element
    current = @context.current_page?(compute_path(element))

    @context.content_tag(:li, :class => ('active' if current)) do
    link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, :class => 'divider') unless current

    link_or_text + (divider || '')
    @context.content_tag(:li, class: ('active' if current)) do
    @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    end
    end
    end
  5. @riyad riyad revised this gist Apr 13, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ def render
    def render_element(element)
    current = @context.current_page?(compute_path(element))

    @context.content_tag(:li, class: ('active' if current)) do
    @context.content_tag(:li, :class => ('active' if current)) do
    link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, :class => 'divider') unless current

  6. @riyad riyad revised this gist Apr 13, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ def render_element(element)

    @context.content_tag(:li, class: ('active' if current)) do
    link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, class: 'divider') unless current
    divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, :class => 'divider') unless current

    link_or_text + (divider || '')
    end
  7. @riyad riyad revised this gist Feb 28, 2012. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,15 @@
    # See SimpleBuilder in https://github.com/weppos/breadcrumbs_on_rails/blob/master/lib/breadcrumbs_on_rails/breadcrumbs.rb
    # The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
    # It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
    #
    # BootstrapBreadcrumbsBuilder accepts a limited set of options:
    # * separator: what should be displayed as a separator between elements
    #
    # You can use it with the :builder option on render_breadcrumbs:
    # <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
    #
    # Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
    # config.autoload_paths += Dir["#{config.root}/lib/"]
    #
    class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
    def render
    @context.content_tag(:ul, class: 'breadcrumb') do
  8. @riyad riyad created this gist Feb 28, 2012.
    21 changes: 21 additions & 0 deletions bootstrap_breadcrumbs_builder.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # See SimpleBuilder in https://github.com/weppos/breadcrumbs_on_rails/blob/master/lib/breadcrumbs_on_rails/breadcrumbs.rb
    class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
    def render
    @context.content_tag(:ul, class: 'breadcrumb') do
    @elements.collect do |element|
    render_element(element)
    end.join.html_safe
    end
    end

    def render_element(element)
    current = @context.current_page?(compute_path(element))

    @context.content_tag(:li, class: ('active' if current)) do
    link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
    divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, class: 'divider') unless current

    link_or_text + (divider || '')
    end
    end
    end