Skip to content

Commit

Permalink
Always put 'kaminari' into the partial path
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki24 committed May 9, 2014
1 parent 987ad89 commit 0a27a1d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions lib/kaminari/helpers/paginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion lib/kaminari/helpers/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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("/")
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/action_view_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("<p>1</p>") }
end
end
Expand Down

0 comments on commit 0a27a1d

Please sign in to comment.