Issue #310 fixed. Refactored code to use a single method to know if a tag page should be displayed.

This commit is contained in:
Anthony Alberto 2013-02-10 16:44:53 -08:00 committed by Akira Matsuda
parent 93dd05ed05
commit 9e181739e8
4 changed files with 8 additions and 3 deletions

View File

@ -11,7 +11,7 @@
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<% if page.display_tag? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>

View File

@ -10,7 +10,7 @@
= first_page_tag unless current_page.first?
= prev_page_tag unless current_page.first?
- each_page do |page|
- if page.left_outer? || page.right_outer? || page.inside_window?
- if page.display_tag?
= page_tag page
- elsif !page.was_truncated?
= gap_tag

View File

@ -11,7 +11,7 @@
== first_page_tag unless current_page.first?
== prev_page_tag unless current_page.first?
- each_page do |page|
- if page.left_outer? || page.right_outer? || page.inside_window?
- if page.display_tag?
== page_tag page
- elsif !page.was_truncated?
== gap_tag

View File

@ -159,6 +159,11 @@ module Kaminari
@last.is_a? Gap
end
#Should we display the link tag?
def display_tag?
left_outer? || right_outer? || inside_window? || single_gap?
end
def to_i #:nodoc:
number
end