

@register.tag
def show_current_number(parser, token):
    'Show the current page number, or insert it in the context.\n\n    This tag can for example be useful to change the page title according to\n    the current page number.\n\n    To just show current page number:\n\n    .. code-block:: html+django\n\n        {% show_current_number %}\n\n    If you use multiple paginations in the same page, you can get the page\n    number for a specific pagination using the querystring key, e.g.:\n\n    .. code-block:: html+django\n\n        {% show_current_number using mykey %}\n\n    The default page when no querystring is specified is 1. If you changed it\n    in the `paginate`_ template tag, you have to call  ``show_current_number``\n    according to your choice, e.g.:\n\n    .. code-block:: html+django\n\n        {% show_current_number starting from page 3 %}\n\n    This can be also achieved using a template variable you passed to the\n    context, e.g.:\n\n    .. code-block:: html+django\n\n        {% show_current_number starting from page page_number %}\n\n    You can of course mix it all (the order of arguments is important):\n\n    .. code-block:: html+django\n\n        {% show_current_number starting from page 3 using mykey %}\n\n    If you want to insert the current page number in the context, without\n    actually displaying it in the template, use the *as* argument, i.e.:\n\n    .. code-block:: html+django\n\n        {% show_current_number as page_number %}\n        {% show_current_number\n            starting from page 3 using mykey as page_number %}\n\n    '
    try:
        (tag_name, args) = token.contents.split(None, 1)
    except ValueError:
        key = None
        number = None
        tag_name = token.contents[0]
        var_name = None
    else:
        match = SHOW_CURRENT_NUMBER_EXPRESSION.match(args)
        if (match is None):
            msg = ('Invalid arguments for %r tag' % tag_name)
            raise template.TemplateSyntaxError(msg)
        groupdict = match.groupdict()
        key = groupdict['key']
        number = groupdict['number']
        var_name = groupdict['var_name']
    return ShowCurrentNumberNode(number, key, var_name)

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