Always put 'kaminari' into the partial path

This commit is contained in:
Yuki Nishijima 2014-05-08 21:22:09 -07:00
parent 987ad89cfe
commit 0a27a1d05c
4 changed files with 8 additions and 4 deletions

View File

@ -170,8 +170,8 @@ Run the following generator command, then edit the generated file.
* specifying an alternative views directory (default is <tt>kaminari/</tt>)
<%= paginate @users, :views_prefix => '../templates/pagination' %>
This would search for partials in <tt>app/views/../templates/pagination</tt>.
<%= paginate @users, :views_prefix => 'templates/' %>
This would search for partials in <tt>app/views/templates/kaminari</tt>. This option makes it easier to do things like A/B testing pagination templates/themes, using new/old templates at the same time as well as better intergration with other gems sush as [cells](https://github.com/apotonick/cells).
* the +link_to_next_page+ and +link_to_previous_page+ helper method

View File

@ -26,6 +26,7 @@ module Kaminari
end
@template, @options = template, options
@theme = @options.delete(:theme)
@views_prefix = @options.delete(:views_prefix)
@window_options.merge! @options
@window_options[:current_page] = @options[:current_page] = PageProxy.new(@window_options, @options[:current_page], nil)

View File

@ -19,6 +19,7 @@ module Kaminari
@template, @options = template, options.dup
@param_name = @options.delete(:param_name) || Kaminari.config.param_name
@theme = @options.delete(:theme)
@views_prefix = @options.delete(:views_prefix)
@params = template.params.except(*PARAM_KEY_BLACKLIST).merge(@options.delete(:params) || {})
end
@ -52,7 +53,9 @@ module Kaminari
end
def partial_path
[@options[:views_prefix] || "kaminari",
[
@views_prefix,
"kaminari",
@theme,
self.class.name.demodulize.underscore
].compact.join("/")

View File

@ -17,7 +17,7 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do
end
context 'accepts :view_prefixes option' do
subject { helper.paginate @users, :views_prefix => "alternative/kaminari" }
subject { helper.paginate @users, :views_prefix => "alternative/" }
it { should eq("<p>1</p>") }
end
end