1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

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>) * specifying an alternative views directory (default is <tt>kaminari/</tt>)
<%= paginate @users, :views_prefix => '../templates/pagination' %> <%= paginate @users, :views_prefix => 'templates/' %>
This would search for partials in <tt>app/views/../templates/pagination</tt>. 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 * the +link_to_next_page+ and +link_to_previous_page+ helper method

View file

@ -26,6 +26,7 @@ module Kaminari
end end
@template, @options = template, options @template, @options = template, options
@theme = @options.delete(:theme) @theme = @options.delete(:theme)
@views_prefix = @options.delete(:views_prefix)
@window_options.merge! @options @window_options.merge! @options
@window_options[:current_page] = @options[:current_page] = PageProxy.new(@window_options, @options[:current_page], nil) @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 @template, @options = template, options.dup
@param_name = @options.delete(:param_name) || Kaminari.config.param_name @param_name = @options.delete(:param_name) || Kaminari.config.param_name
@theme = @options.delete(:theme) @theme = @options.delete(:theme)
@views_prefix = @options.delete(:views_prefix)
@params = template.params.except(*PARAM_KEY_BLACKLIST).merge(@options.delete(:params) || {}) @params = template.params.except(*PARAM_KEY_BLACKLIST).merge(@options.delete(:params) || {})
end end
@ -52,7 +53,9 @@ module Kaminari
end end
def partial_path def partial_path
[@options[:views_prefix] || "kaminari", [
@views_prefix,
"kaminari",
@theme, @theme,
self.class.name.demodulize.underscore self.class.name.demodulize.underscore
].compact.join("/") ].compact.join("/")

View file

@ -17,7 +17,7 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do
end end
context 'accepts :view_prefixes option' do 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>") } it { should eq("<p>1</p>") }
end end
end end