diff --git a/README.rdoc b/README.rdoc index c410a3055..d4069c92a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -170,8 +170,8 @@ Run the following generator command, then edit the generated file. * specifying an alternative views directory (default is kaminari/) - <%= paginate @users, :views_prefix => '../templates/pagination' %> - This would search for partials in app/views/../templates/pagination. + <%= paginate @users, :views_prefix => 'templates/' %> + This would search for partials in app/views/templates/kaminari. 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 diff --git a/lib/kaminari/helpers/paginator.rb b/lib/kaminari/helpers/paginator.rb index 4c4881a51..1d75143fe 100644 --- a/lib/kaminari/helpers/paginator.rb +++ b/lib/kaminari/helpers/paginator.rb @@ -26,6 +26,7 @@ def initialize(template, options) #:nodoc: 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) diff --git a/lib/kaminari/helpers/tags.rb b/lib/kaminari/helpers/tags.rb index d7fb88b5c..9e27b8c44 100644 --- a/lib/kaminari/helpers/tags.rb +++ b/lib/kaminari/helpers/tags.rb @@ -19,6 +19,7 @@ def initialize(template, options = {}) #:nodoc: @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 @@ def params_for(page) end def partial_path - [@options[:views_prefix] || "kaminari", + [ + @views_prefix, + "kaminari", @theme, self.class.name.demodulize.underscore ].compact.join("/") diff --git a/spec/helpers/action_view_extension_spec.rb b/spec/helpers/action_view_extension_spec.rb index af88569e6..05c220186 100644 --- a/spec/helpers/action_view_extension_spec.rb +++ b/spec/helpers/action_view_extension_spec.rb @@ -17,7 +17,7 @@ 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("

1

") } end end