Skip to content
Browse files

Render element without <a> if path == nil.

  • Loading branch information...
1 parent 71c6eda commit a2d7328de5cdf006be19cf9e6704f83d4d094b5f @mpartel mpartel committed Sep 26, 2012
Showing with 13 additions and 1 deletion.
  1. +5 −1 lib/breadcrumbs_on_rails/breadcrumbs.rb
  2. +8 −0 test/unit/simple_builder_test.rb
View
6 lib/breadcrumbs_on_rails/breadcrumbs.rb
@@ -87,7 +87,11 @@ def render
end
def render_element(element)
- content = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
+ 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 @options[:tag]
@context.content_tag(@options[:tag], content)
else
View
8 test/unit/simple_builder_test.rb
@@ -52,6 +52,14 @@ def test_render_with_current_page
simplebuilder(@template, generate_elements(2)).render)
end
+ def test_render_with_no_links
+ elements = (1..2).collect do |index|
+ BreadcrumbsOnRails::Breadcrumbs::Element.new("Element #{index}", nil)
+ end
+ assert_dom_equal("Element 1 &raquo; Element 2",
+ simplebuilder(@template, elements).render)
+ end
+
protected

0 comments on commit a2d7328

Please sign in to comment.
Something went wrong with that request. Please try again.