@register.tag
def mkrange(parser, token):
 tokens = token.split_contents()
 fnctl = tokens.pop(0)
 def error():
  raise TemplateSyntaxError, (('%s accepts the syntax: {%% %s [start,] ' + "stop[, step] as context_name %%}, where 'start', 'stop' ") + ("and 'step' must all be integers." % (fnctl, fnctl)))
 range_args = []
 while True:
  if (len(tokens) < 2):
   error()
  token = tokens.pop(0)
  if (token == 'as'):
   break
  range_args.append(token)
 if (len(tokens) != 1):
  error()
 context_name = tokens.pop()
 return RangeNode(parser, range_args, context_name)

@ register . tag def mkrange ( parser , token ) : tokens = token . split_contents ( ) fnctl = tokens . pop ( 0 ) def error ( ) : raise TemplateSyntaxError , ( ( '%s accepts the syntax: {%% %s [start,] ' + "stop[, step] as context_name %%}, where 'start', 'stop' " ) + ( "and 'step' must all be integers." % ( fnctl , fnctl ) ) ) range_args = [ ] while True : if ( len ( tokens ) < 2 ) : error ( ) token = tokens . pop ( 0 ) if ( token == 'as' ) : break range_args . append ( token ) if ( len ( tokens ) != 1 ) : error ( ) context_name = tokens . pop ( ) return RangeNode ( parser , range_args , context_name )
accepts the same arguments as the range builtin and creates a list containing the result of range .