diff --git a/lib/will_paginate/view_helpers.rb b/lib/will_paginate/view_helpers.rb index 5056c03cb..089f5bf2b 100644 --- a/lib/will_paginate/view_helpers.rb +++ b/lib/will_paginate/view_helpers.rb @@ -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. diff --git a/lib/will_paginate/view_helpers/action_view.rb b/lib/will_paginate/view_helpers/action_view.rb index a3a89c707..6fa29295c 100644 --- a/lib/will_paginate/view_helpers/action_view.rb +++ b/lib/will_paginate/view_helpers/action_view.rb @@ -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: diff --git a/spec/view_helpers/base_spec.rb b/spec/view_helpers/base_spec.rb index 77542bd34..5fd97f142 100644 --- a/spec/view_helpers/base_spec.rb +++ b/spec/view_helpers/base_spec.rb @@ -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