Sha256: 9a4f9e904a2845d2a715bdc7e3a311a9a7c8f53f82f28a66bfeb6e7313d3f936

Contents?: true

Size: 1.3 KB

Versions: 26

Compression:

Stored size: 1.3 KB

Contents

require 'kaminari'

module Kaminari

  module Helpers
    class Tag
      def to_s(locals = {})
        path = "kaminari/#{@theme}#{self.class.name.demodulize.underscore}"

        if namespace = @options[:namespace]
          path = "#{namespace}/#{path}"
        end

        @template.render partial: path, locals: @options.merge(locals)
      end
    end
  end

  class PaginatableArray < Array
    def to_liquid(options = {})
      {
        collection:       to_a,
        current_page:     current_page,
        previous_page:    first_page? ? nil : current_page - 1,
        next_page:        last_page? ? nil : current_page + 1,
        total_entries:    total_count,
        total_pages:      num_pages,
        per_page:         limit_value
      }
    end
  end

  module PageScopeMethods

   def to_liquid(options = {})
     {
       collection:       to_a,
       current_page:     current_page,
       previous_page:    first_page? ? nil : current_page - 1,
       total_entries:    total_count,
       per_page:         limit_value
     }.tap do |hash|
       # note: very important to avoid extra and useless mongodb requests
       hash[:total_pages] = (hash[:total_entries].to_f / limit_value).ceil
       hash[:next_page]   = current_page >= hash[:total_pages] ? nil : current_page + 1
     end
   end

  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 lib/locomotive/kaminari.rb
locomotive_cms-2.5.6 lib/locomotive/kaminari.rb
locomotive_cms-2.5.6.rc2 lib/locomotive/kaminari.rb
locomotive_cms-2.5.6.rc1 lib/locomotive/kaminari.rb
locomotive_cms-2.5.5 lib/locomotive/kaminari.rb
locomotive_cms-2.5.4 lib/locomotive/kaminari.rb
locomotive_cms-2.5.3 lib/locomotive/kaminari.rb
locomotive_cms-2.5.2 lib/locomotive/kaminari.rb
locomotive_cms-2.5.1 lib/locomotive/kaminari.rb
locomotive_cms-2.5.0 lib/locomotive/kaminari.rb
locomotive_cms-2.5.0.rc3 lib/locomotive/kaminari.rb
locomotive_cms-2.5.0.rc2 lib/locomotive/kaminari.rb
locomotive_cms-2.5.0.rc1 lib/locomotive/kaminari.rb
locomotive_cms-2.4.1 lib/locomotive/kaminari.rb
locomotive_cms-2.4.0 lib/locomotive/kaminari.rb
locomotive_cms-2.3.1 lib/locomotive/kaminari.rb
locomotive_cms-2.3.0 lib/locomotive/kaminari.rb
locomotive_cms-2.2.3 lib/locomotive/kaminari.rb
locomotive_cms-2.2.2 lib/locomotive/kaminari.rb
locomotive_cms-2.2.1 lib/locomotive/kaminari.rb