Permalink
Browse files

Merge pull request #101 from a0903638/master

add support for :join_with to links
  • Loading branch information...
2 parents 728e5ae + e74d59c commit 639eb2fa0ecfcb9ec78164b5f9ac795d37d03341 @andi andi committed Aug 18, 2012
@@ -14,11 +14,16 @@ class Links < SimpleNavigation::Renderer::Base
def render(item_container)
div_content = item_container.items.inject([]) do |list, item|
list << tag_for(item)
- end.join
+ end.join(join_with)
content_tag(:div, div_content, {:id => item_container.dom_id, :class => item_container.dom_class})
end
protected
+
+ def join_with
+ @join_with ||= options[:join_with] || ""
+ end
+
def options_for(item)
{:method => item.method}.merge(item.html_options)
end
@@ -51,6 +51,12 @@ def render(current_nav=nil, options={:level => :all})
HTML::Selector.new('a.selected').select(render).should be_empty
end
end
+
+ context 'with a custom seperator specified' do
+ it "should separate the items with the separator" do
+ HTML::Selector.new('div').select_first(render(:subnav1, :join_with => " | ")).to_s.split(" | ").should have(4).entries
+ end
+ end
end

0 comments on commit 639eb2f

Please sign in to comment.