Class: PaginationDrop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
app/drops/pagination_drop.rb

Overview

Accessible using the paginate variable inside a paginate tag. You can use the paginate tag to paginate an array of items and then use the paginate variable inside it to access different values based on the current page. See the below example

Examples:

Pagination example

{% assign items = "a,b,c,d,e,f,g,h" | split: ',' %}
{% paginate items by 3 %}
  {% for item in items %}
    Hey {{ item }}
  {% endfor %}

  Items per page: {{ paginate.page_size }}
  Current page: {{ paginate.current_offset | plus: 1 }}
  {% if paginate.next %}
    Next url: {{ paginate.next.url ]}
  {% endif %}
{% endpaginate %}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageInteger

Returns the current page number

Returns:

  • (Integer)

#page_sizeInteger

Returns the maximum number of items in one page

Returns:

  • (Integer)

#pagesInteger

Returns the total numbers of pages

Returns:

  • (Integer)

Instance Method Details

#current_offsetInteger

Returns the index of the starting item in the current page (0-indexed).

Returns:

  • (Integer)

#itemsInteger

Returns the total number of items

Returns:

  • (Integer)

#nextPaginationPartDrop

Returns the PaginationPartDrop for the next page if available

Returns:

#partsArray<PaginationPartDrop>

Returns an array of PaginationPartDrop based on the current pagination context. Includes the parts for the first page, last page and 2 pages before & after the current page. Also include placeholder parts ('…') if the current page >= 5 or there are more than 3 pages left from the current page to reach the end .

Returns:

#previousPaginationPartDrop

Returns the PaginationPartDrop for the previous page if available

Returns: