Added will paginate to liquid.

This commit is contained in:
Mario Visic 2011-10-24 23:44:35 +08:00
parent e6abd6bbe0
commit 786d2d9693
3 changed files with 15 additions and 1 deletions

View File

@ -1 +1,2 @@
require 'will_paginate/array' require 'will_paginate/array'
require 'locomotive/liquid/drops/will_paginate_extension'

View File

@ -0,0 +1,13 @@
class WillPaginate::Collection
def to_liquid
{
:collection => self.to_a,
:current_page => current_page,
:previous_page => previous_page,
:next_page => next_page,
:total_entries => total_entries,
:total_pages => total_pages,
:per_page => per_page
}
end
end

View File

@ -38,7 +38,7 @@ module Locomotive
pagination = collection.send(:paginate, { pagination = collection.send(:paginate, {
:page => context['current_page'], :page => context['current_page'],
:per_page => @per_page }).stringify_keys :per_page => @per_page }).to_liquid.stringify_keys
page_count, current_page = pagination['total_pages'], pagination['current_page'] page_count, current_page = pagination['total_pages'], pagination['current_page']