diff --git a/lib/will_paginate/view_helpers.rb b/lib/will_paginate/view_helpers.rb
index c53e44ec5..fee3ad7a4 100644
--- a/lib/will_paginate/view_helpers.rb
+++ b/lib/will_paginate/view_helpers.rb
@@ -14,24 +14,24 @@ module WillPaginate
# WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to
# override default options on the global level:
#
- # WillPaginate::ViewHelpers.pagination_options[:prev_label] = 'Previous page'
+ # WillPaginate::ViewHelpers.pagination_options[:previous_label] = 'Previous page'
#
# By putting this into your environment.rb you can easily translate link texts to previous
# and next pages, as well as override some other defaults to your liking.
module ViewHelpers
# default options that can be overridden on the global level
@@pagination_options = {
- :class => 'pagination',
- :prev_label => '« Previous',
- :next_label => 'Next »',
- :inner_window => 4, # links around the current page
- :outer_window => 1, # links around beginning and end
- :separator => ' ', # single space is friendly to spiders and non-graphic browsers
- :param_name => :page,
- :params => nil,
- :renderer => 'WillPaginate::LinkRenderer',
- :page_links => true,
- :container => true
+ :class => 'pagination',
+ :previous_label => '« Previous',
+ :next_label => 'Next »',
+ :inner_window => 4, # links around the current page
+ :outer_window => 1, # links around beginning and end
+ :separator => ' ', # single space is friendly to spiders and non-graphic browsers
+ :param_name => :page,
+ :params => nil,
+ :renderer => 'WillPaginate::LinkRenderer',
+ :page_links => true,
+ :container => true
}
mattr_reader :pagination_options
@@ -41,7 +41,7 @@ module ViewHelpers
#
# ==== Options
# * :class -- CSS class name for the generated DIV (default: "pagination")
- # * :prev_label -- default: "« Previous"
+ # * :previous_label -- default: "« Previous"
# * :next_label -- default: "Next »"
# * :inner_window -- how many links are shown around the current page (default: 4)
# * :outer_window -- how many links are around the first and the last page (default: 1)
@@ -92,6 +92,10 @@ def will_paginate(collection = nil, options = {})
return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1
options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
+ if options[:prev_label]
+ WillPaginate::Deprecation::warn(":prev_label view parameter is now :previous_label; the old name has been deprecated.")
+ options[:previous_label] = options.delete(:prev_label)
+ end
# get the renderer instance
renderer = case options[:renderer]
@@ -214,7 +218,7 @@ def prepare(collection, options, template)
def to_html
links = @options[:page_links] ? windowed_links : []
# previous/next buttons
- links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:prev_label])
+ links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label])
html = links.join(@options[:separator])
diff --git a/test/view_test.rb b/test/view_test.rb
index b6d1a207f..bd6b77f82 100644
--- a/test/view_test.rb
+++ b/test/view_test.rb
@@ -36,7 +36,7 @@ def test_no_pagination_when_page_count_is_one
def test_will_paginate_with_options
paginate({ :page => 2 },
- :class => 'will_paginate', :prev_label => 'Prev', :next_label => 'Next') do
+ :class => 'will_paginate', :previous_label => 'Prev', :next_label => 'Next') do
assert_select 'a[href]', 4 do |elements|
validate_page_numbers [1,1,3,3], elements
# test rel attribute values:
@@ -80,6 +80,14 @@ def test_prev_next_links_have_classnames
assert_select 'a.next_page[href]:last-child'
end
end
+
+ def test_prev_label_deprecated
+ assert_deprecated ':previous_label' do
+ paginate({ :page => 2 }, :prev_label => 'Deprecated') do
+ assert_select 'a[href]:first-child', 'Deprecated'
+ end
+ end
+ end
def test_full_output
paginate