@register_tag<EOL>def get_range_around(range_value, current_item, padding):
total_items = <NUM_LIT:1> + padding * <NUM_LIT:2><EOL>left_bound = padding<EOL>right_bound = range_value - padding<EOL>if range_value <= total_items:<EOL><INDENT>range_items = range(<NUM_LIT:1>, range_value + <NUM_LIT:1>)<EOL>return {<EOL>'<STR_LIT>': range_items,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': False,<EOL>}<EOL><DEDENT>if current_item <= left_bound:<EOL><INDENT>range_items = range(<NUM_LIT:1>, range_value + <NUM_LIT:1>)[:total_items]<EOL>return {<EOL>'<STR_LIT>': range_items,<EOL>'<STR_LIT>': range_items[<NUM_LIT:0>] > <NUM_LIT:1>,<EOL>'<STR_LIT>': range_items[-<NUM_LIT:1>] < range_value,<EOL>}<EOL><DEDENT>if current_item >= right_bound:<EOL><INDENT>range_items = range(<NUM_LIT:1>, range_value + <NUM_LIT:1>)[-total_items:]<EOL>return {<EOL>'<STR_LIT>': range_items,<EOL>'<STR_LIT>': range_items[<NUM_LIT:0>] > <NUM_LIT:1>,<EOL>'<STR_LIT>': range_items[-<NUM_LIT:1>] < range_value,<EOL>}<EOL><DEDENT>range_items = range(current_item - padding, current_item + padding + <NUM_LIT:1>)<EOL>return {<EOL>'<STR_LIT>': range_items,<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': True,<EOL>}<EOL>
Returns a range of numbers around the given number.

This is useful for pagination, where you might want to show something
like this::

    << < ... 4 5 (6) 7 8 .. > >>

In this example `6` would be the current page and we show 2 items around
that page (including the page itself).

Usage::

    {% load libs_tags %}
    {% get_range_around page_obj.paginator.num_pages page_obj.number 5
      as pages %}

:param range_amount: Number of total items in your range (1 indexed)
:param current_item: The item around which the result should be centered
  (1 indexed)
:param padding: Number of items to show left and right from the current
  item.