

@register.tag
def get_pages(parser, token):
    'Add to context the list of page links.\n\n    Usage:\n\n    .. code-block:: html+django\n\n        {% get_pages %}\n\n    This is mostly used for Digg-style pagination.\n    This call inserts in the template context a *pages* variable, as a sequence\n    of page links. You can use *pages* in different ways:\n\n    - just print *pages* and you will get Digg-style pagination displayed:\n\n    .. code-block:: html+django\n\n        {{ pages }}\n\n    - display pages count:\n\n    .. code-block:: html+django\n\n        {{ pages|length }}\n\n    - check if the page list contains more than one page:\n\n    .. code-block:: html+django\n\n        {{ pages.paginated }}\n        {# the following is equivalent #}\n        {{ pages|length > 1 }}\n\n    - get a specific page:\n\n    .. code-block:: html+django\n\n        {# the current selected page #}\n        {{ pages.current }}\n\n        {# the first page #}\n        {{ pages.first }}\n\n        {# the last page #}\n        {{ pages.last }}\n\n        {# the previous page (or nothing if you are on first page) #}\n        {{ pages.previous }}\n\n        {# the next page (or nothing if you are in last page) #}\n        {{ pages.next }}\n\n        {# the third page #}\n        {{ pages.3 }}\n        {# this means page.1 is the same as page.first #}\n\n        {# the 1-based index of the first item on the current page #}\n        {{ pages.current_start_index }}\n\n        {# the 1-based index of the last item on the current page #}\n        {{ pages.current_end_index }}\n\n        {# the total number of objects, across all pages #}\n        {{ pages.total_count }}\n\n        {# the first page represented as an arrow #}\n        {{ pages.first_as_arrow }}\n\n        {# the last page represented as an arrow #}\n        {{ pages.last_as_arrow }}\n\n    - iterate over *pages* to get all pages:\n\n    .. code-block:: html+django\n\n        {% for page in pages %}\n            {# display page link #}\n            {{ page }}\n\n            {# the page url (beginning with "?") #}\n            {{ page.url }}\n\n            {# the page path #}\n            {{ page.path }}\n\n            {# the page number #}\n            {{ page.number }}\n\n            {# a string representing the page (commonly the page number) #}\n            {{ page.label }}\n\n            {# check if the page is the current one #}\n            {{ page.is_current }}\n\n            {# check if the page is the first one #}\n            {{ page.is_first }}\n\n            {# check if the page is the last one #}\n            {{ page.is_last }}\n        {% endfor %}\n\n    You can change the variable name, e.g.:\n\n    .. code-block:: html+django\n\n        {% get_pages as page_links %}\n\n    Must be called after ``{% paginate objects %}``.\n    '
    try:
        (tag_name, args) = token.contents.split(None, 1)
    except ValueError:
        var_name = 'pages'
    else:
        args = args.split()
        if ((len(args) == 2) and (args[0] == 'as')):
            var_name = args[1]
        else:
            msg = ('Invalid arguments for %r tag' % tag_name)
            raise template.TemplateSyntaxError(msg)
    return GetPagesNode(var_name)

dataset/ETHPy150Open frankban/django-endless-pagination/endless_pagination/templatetags/endless.py get_pages/original