Sha256: 029342a38e6df1822495e005bc5a8e92db61c7f238f957d36c373b63e5870b83

Contents?: true

Size: 837 Bytes

Versions: 6

Compression:

Stored size: 837 Bytes

Contents

module HtmlHelper

  def paginate list
    return unless list.respond_to?(:paginate_next)
    return nil if list.paginate_page == 1 && !list.paginate_next

    ret = ['<div class="paginate"><div>']

    if list.paginate_page > 1
      url = Url.current
      list.paginate_page == 1 ? url.delete(list.paginate_param) : url.qs(list.paginate_param, list.paginate_page-1)
      ret.push %[<a href="#{url.relative}">&larr;</a>]
    else
      ret.push %[<span>&larr;</span>]
    end

    ret.push %[<i>#{list.paginate_page == 1 ? '&bull;' : list.paginate_page}</i>]

    if list.paginate_next
      url = Url.current
      url.qs(list.paginate_param, list.paginate_page+1)
      ret.push %[<a href="#{url.relative}">&rarr;</a>]
    else
      ret.push %[<span>&rarr;</span>]
    end

    ret.push '</div></div>'
    ret.join('')
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lux-fw-0.5.37 ./plugins/db/paginate/helper.rb
lux-fw-0.5.36 ./plugins/db/paginate/helper.rb
lux-fw-0.5.35 ./plugins/db/paginate/helper.rb
lux-fw-0.5.34 ./plugins/db/paginate/helper.rb
lux-fw-0.5.33 ./plugins/db/paginate/helper.rb
lux-fw-0.5.32 ./plugins/db/paginate/helper.rb