Slices a paginator.
    
    Syntax:
    {% sliced_pagination page 5 as sliced_paginator %}
    
    where
     - page is an instance of the Django `Page` class.
     - max_items are the number of items to be shown in total. Ie., 5 will yield
        << 1 2 3 4 5 ... >>
       or
        << ... 4 5 6 7 8 ... >>
       or
        << ... 10 11 12 13 15 >>
       Currently only uneven numbers are supported for this parameter due to
       have even lists of pages on both sides.
    
    Sample syntax to use the sliced paginator:
    {% if sliced_paginator.hidden_prev_pages %}
    ...
    {% endif %}
    {% for pageno in sliced_paginator.prev_pages %}
        <a href="?page={{ pageno }}">{{ pageno}}</a>
    {% endfor %}
    <a href="#" class="current">{{ page.number }}</a>
    {% for pageno in sliced_paginator.next_pages %}
        <a href="?page={{ pageno }}">{{ pageno}}</a>
    {% endfor %}
    {% if sliced_paginator.hidden_next_pages %}
    ...
    {% endif %}
    
    Produces:
    ...           # only shown if needed
    <a href="?page=3">3</a>
    <a href="?page=4">4</a>
    <a href="#" class="current">5</a>
    <a href="?page=6">6</a>
    <a href="?page=7">7</a>
    ...           # only shown if needed

def sliced_pagination(parser, token):
    """
    Slices a paginator.
    
    Syntax:
    {% sliced_pagination page 5 as sliced_paginator %}
    
    where
     - page is an instance of the Django `Page` class.
     - max_items are the number of items to be shown in total. Ie., 5 will yield
        << 1 2 3 4 5 ... >>
       or
        << ... 4 5 6 7 8 ... >>
       or
        << ... 10 11 12 13 15 >>
       Currently only uneven numbers are supported for this parameter due to
       have even lists of pages on both sides.
    
    Sample syntax to use the sliced paginator:
    {% if sliced_paginator.hidden_prev_pages %}
    ...
    {% endif %}
    {% for pageno in sliced_paginator.prev_pages %}
        <a href="?page={{ pageno }}">{{ pageno}}</a>
    {% endfor %}
    <a href="#" class="current">{{ page.number }}</a>
    {% for pageno in sliced_paginator.next_pages %}
        <a href="?page={{ pageno }}">{{ pageno}}</a>
    {% endfor %}
    {% if sliced_paginator.hidden_next_pages %}
    ...
    {% endif %}
    
    Produces:
    ...           # only shown if needed
    <a href="?page=3">3</a>
    <a href="?page=4">4</a>
    <a href="#" class="current">5</a>
    <a href="?page=6">6</a>
    <a href="?page=7">7</a>
    ...           # only shown if needed
    
    """
    try:
        fnctn, paginatorname, max_items, trash, context_name = token.split_contents()
    except ValueError:
        raise TemplateSyntaxError, _get_errstr(fnctn)
    if not trash == 'as':
        raise TemplateSyntaxError, _get_errstr(fnctn)
    return _PaginatorSliceNode(context_name, paginatorname, max_items)