diff --git a/lib/will_paginate/view_helpers/link_renderer.rb b/lib/will_paginate/view_helpers/link_renderer.rb index f430492a..7fc21f13 100644 --- a/lib/will_paginate/view_helpers/link_renderer.rb +++ b/lib/will_paginate/view_helpers/link_renderer.rb @@ -103,13 +103,12 @@ def link(text, target, attributes = {}) end def tag(name, value, attributes = {}) - string_attributes = attributes.inject('') do |attrs, pair| + string_attributes = attributes.map do |pair| unless pair.last.nil? - attrs << %( #{pair.first}="#{CGI::escapeHTML(pair.last.to_s)}") + %( #{pair.first}="#{CGI::escapeHTML(pair.last.to_s)}") end - attrs end - "<#{name}#{string_attributes}>#{value}#{name}>" + "<#{name}#{string_attributes.compact.join("")}>#{value}#{name}>" end def rel_value(page) diff --git a/spec/view_helpers/action_view_spec.rb b/spec/view_helpers/action_view_spec.rb index fd844516..2faaa990 100644 --- a/spec/view_helpers/action_view_spec.rb +++ b/spec/view_helpers/action_view_spec.rb @@ -126,14 +126,13 @@ def renderer.gap() '~~' end it "should match expected markup" do paginate - expected = <<-HTML + expected = <<-HTML.strip.gsub(/\s{2,}/, ' ')
HTML - expected.strip!.gsub!(/\s{2,}/, ' ') expected_dom = parse_html_document(expected) if expected_dom.respond_to?(:canonicalize)