Skip to content
Permalink
Browse files

Merge pull request #72 from murny/improve-rel-logic

Use page.rel helper from kaminari instead of complex conditional logic
  • Loading branch information
yuki24 committed May 23, 2019
2 parents c9a79f5 + 18402aa commit 6a73ffc2c418e1998b962242e19b6db9cac4c9f7
@@ -1,9 +1,9 @@
<% if page.current? %>
<li class='active'>
<%= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
<%= content_tag :a, page, data: { remote: remote }, rel: page.rel %>
</li>
<% else %>
<li>
<%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
<%= link_to page, url, remote: remote, rel: page.rel %>
</li>
<% end %>
@@ -1,6 +1,6 @@
- if page.current?
%li.active
= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil))
= content_tag :a, page, data: { remote: remote }, rel: page.rel
- else
%li
= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil))
= link_to page, url, remote: remote, rel: page.rel
@@ -1,2 +1,2 @@
li class="#{'active' if page.current?}"
= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.rel}
@@ -1,9 +1,9 @@
<% if page.current? %>
<li class='active'>
<%= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
<%= content_tag :a, page, data: { remote: remote }, rel: page.rel %>
</li>
<% else %>
<li>
<%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
<%= link_to page, url, remote: remote, rel: page.rel %>
</li>
<% end %>
@@ -1,6 +1,6 @@
- if page.current?
%li.active
= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil))
= content_tag :a, page, data: { remote: remote }, rel: page.rel
- else
%li
= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil))
= link_to page, url, remote: remote, rel: page.rel
@@ -1,3 +1,3 @@
li class="#{'active' if page.current?}"
= link_to page, page.current? ? '#' : url,
remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil
remote: remote, rel: page.rel
@@ -1,9 +1,9 @@
<% if page.current? %>
<li class="page-item active">
<%= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %>
<%= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link' %>
</li>
<% else %>
<li class="page-item">
<%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %>
<%= link_to page, url, remote: remote, rel: page.rel, class: 'page-link' %>
</li>
<% end %>
@@ -1,6 +1,6 @@
- if page.current?
%li.page-item.active
= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link'
= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link'
- else
%li.page-item
= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link'
= link_to page, url, remote: remote, rel: page.rel, class: 'page-link'
@@ -1,6 +1,6 @@
- if page.current?
li.page-item.active
= content_tag :a, page, data: { remote: remote }, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link'
= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link'
- else
li.page-item
= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link'
= link_to page, url, remote: remote, rel: page.rel, class: 'page-link'
@@ -2,6 +2,6 @@
<% if page.current? %>
<%= link_to page, "#" %>
<% else %>
<%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
<%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.rel} %>
<% end %>
</li>
</li>
@@ -2,4 +2,4 @@
- if page.current?
= link_to page, "#"
- else
= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.rel}
@@ -2,4 +2,4 @@ li class="page#{' current' if page.current?}"
- if page.current?
= link_to page, "#"
- else
= link_to_unless page.current?, page, url, remote: remote, rel: (page.next? ? 'next' : page.prev? ? 'prev' : nil)
= link_to_unless page.current?, page, url, remote: remote, rel: page.rel
@@ -2,6 +2,6 @@
<% if page.current? %>
<%= page %>
<% else %>
<%= link_to page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
<%= link_to page, url, {:remote => remote, :rel => page.rel} %>
<% end %>
</li>
@@ -2,4 +2,4 @@
- if page.current?
= page
- else
= link_to page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to page, url, {:remote => remote, :rel => page.rel}
@@ -2,4 +2,4 @@ li class="#{'current' if page.current?}"
- if page.current?
= page
- else
= link_to page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to page, url, {:remote => remote, :rel => page.rel}
@@ -1,3 +1,3 @@
<li class="<%= 'current' if page.current? %>">
<%= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
<%= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.rel} %>
</li>
@@ -1,2 +1,2 @@
%li{class: "#{'current' if page.current?}"}
= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to page, page.current? ? '#' : url, {:remote => remote, :rel => page.rel}
@@ -1,4 +1,4 @@
li{class="#{'current' if page.current?}"}
= link_to(page, page.current? ? '#' : url,
{ :remote => remote,
:rel => page.next? ? 'next' : page.prev? ? 'prev' : nil })
:rel => page.rel})
@@ -1,3 +1,3 @@
<li class="pure-u-1-24">
<%= link_to page, url, {:class => "pure-button#{' pure-button-active' if page.current?}", :remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
<%= link_to page, url, {:class => "pure-button#{' pure-button-active' if page.current?}", :remote => remote, :rel => page.rel} %>
</li>
@@ -1,2 +1,2 @@
%li.pure-u-1-24
= link_to page, url, {:class => "pure-button#{' pure-button-active' if page.current?}", :remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to page, url, {:class => "pure-button#{' pure-button-active' if page.current?}", :remote => remote, :rel => page.rel}
@@ -1,2 +1,2 @@
li.pure-u-1-24
= link_to page, url, {:class => "pure-button#{' pure-button-active' if page.current?}", :remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
= link_to page, url, {:class => "pure-button#{' pure-button-active' if page.current?}", :remote => remote, :rel => page.rel}

0 comments on commit 6a73ffc

Please sign in to comment.
You can’t perform that action at this time.