class Knitkit::Extensions::WillPaginate::LinkRenderer

Protected Instance Methods

html_container(html) click to toggle source
# File lib/knitkit/extensions/will_paginate/link_renderer.rb, line 41
def html_container(html)
  tag(:ul, html, :class => 'pagination')
end
next_page() click to toggle source
# File lib/knitkit/extensions/will_paginate/link_renderer.rb, line 28
def next_page
  num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
  previous_or_next_page(num, '&raquo;')
end
page_number(page) click to toggle source
# File lib/knitkit/extensions/will_paginate/link_renderer.rb, line 10
def page_number(page)
  unless page == current_page
    tag(:li, link(page, page, :rel => rel_value(page)))
  else
    tag(
        :li,
        tag(:a, "#{page} #{tag(:span, '(current)', :class => 'sr-only')}"),
        :class => 'active'
    )

  end
end
previous_or_next_page(page, text) click to toggle source
# File lib/knitkit/extensions/will_paginate/link_renderer.rb, line 33
def previous_or_next_page(page, text)
  if page
    tag(:li, link(text, page))
  else
    tag(:li, link(text, 'javascript:void('');'), :class => 'disabled')
  end
end
previous_page() click to toggle source
# File lib/knitkit/extensions/will_paginate/link_renderer.rb, line 23
def previous_page
  num = @collection.current_page > 1 && @collection.current_page - 1
  previous_or_next_page(num, '&laquo;')
end
url(page) click to toggle source
# File lib/knitkit/extensions/will_paginate/link_renderer.rb, line 45
def url(page)
  @base_url_params ||= begin
    url_params = merge_get_params(default_url_params)
    merge_optional_params(url_params)
  end

  url_params = @base_url_params.dup
  add_current_page_param(url_params, page)

  if url_params[:scope]
    scope = url_params[:scope]
    url_params.delete(:scope)

    scope.url_for(url_params)
  else
    @template.url_for(url_params)
  end
end