Permalink
Browse files

always call `html_safe` on will_paginate result

This ensures that the HTML output of `will_paginate` view helper is not
only marked safe in Rails, but in Padrino as well.
  • Loading branch information...
1 parent 0da1688 commit 4cb4986d5ce05aa84572b05cfd1c1d0aa9bc07df @mislav committed Sep 16, 2013
@@ -91,7 +91,9 @@ def will_paginate(collection, options = {})
end
# render HTML for pagination
renderer.prepare collection, options, self
- renderer.to_html
+ output = renderer.to_html
+ output = output.html_safe if output.respond_to?(:html_safe)
+ output
end
# Renders a message containing number of displayed vs. total entries.
@@ -30,7 +30,7 @@ def will_paginate(collection = nil, options = {}) #:nodoc:
options = options.symbolize_keys
options[:renderer] ||= LinkRenderer
- super(collection, options).try(:html_safe)
+ super(collection, options)
end
def page_entries_info(collection = nil, options = {}) #:nodoc:
@@ -32,6 +32,18 @@
collection = mock 'Collection', :total_pages => 1
will_paginate(collection).should be_nil
end
+
+ it "should call html_safe on result" do
+ collection = WillPaginate::Collection.new(1, 2, 4)
+
+ html = mock 'HTML'
+ html.expects(:html_safe).returns(html)
+ renderer = mock 'Renderer'
+ renderer.stubs(:prepare)
+ renderer.expects(:to_html).returns(html)
+
+ will_paginate(collection, :renderer => renderer).should eql(html)
+ end
end
describe "pagination_options" do

0 comments on commit 4cb4986

Please sign in to comment.