@register.tag('include')
def do_include(parser, token):
 bits = token.split_contents()
 if (len(bits) < 2):
  raise TemplateSyntaxError(('%r tag takes at least one argument: the name of the template to be included.' % bits[0]))
 options = {}
 remaining_bits = bits[2:]
 while remaining_bits:
  option = remaining_bits.pop(0)
  if (option in options):
   raise TemplateSyntaxError(('The %r option was specified more than once.' % option))
  if (option == 'with'):
   value = token_kwargs(remaining_bits, parser, support_legacy=False)
   if (not value):
    raise TemplateSyntaxError(('"with" in %r tag needs at least one keyword argument.' % bits[0]))
  elif (option == 'only'):
   value = True
  else:
   raise TemplateSyntaxError(('Unknown argument for %r tag: %r.' % (bits[0], option)))
  options[option] = value
 isolated_context = options.get('only', False)
 namemap = options.get('with', {})
 path = bits[1]
 if ((path[0] in ('"', "'")) and (path[(-1)] == path[0])):
  return ConstantIncludeNode(path[1:(-1)], extra_context=namemap, isolated_context=isolated_context)
 return IncludeNode(parser.compile_filter(bits[1]), extra_context=namemap, isolated_context=isolated_context)

@ register . tag ( 'include' ) def do_include ( parser , token ) : bits = token . split_contents ( ) if ( len ( bits ) < 2 ) : raise TemplateSyntaxError ( ( '%r tag takes at least one argument: the name of the template to be included.' % bits [ 0 ] ) ) options = { } remaining_bits = bits [ 2 : ] while remaining_bits : option = remaining_bits . pop ( 0 ) if ( option in options ) : raise TemplateSyntaxError ( ( 'The %r option was specified more than once.' % option ) ) if ( option == 'with' ) : value = token_kwargs ( remaining_bits , parser , support_legacy = False ) if ( not value ) : raise TemplateSyntaxError ( ( '"with" in %r tag needs at least one keyword argument.' % bits [ 0 ] ) ) elif ( option == 'only' ) : value = True else : raise TemplateSyntaxError ( ( 'Unknown argument for %r tag: %r.' % ( bits [ 0 ] , option ) ) ) options [ option ] = value isolated_context = options . get ( 'only' , False ) namemap = options . get ( 'with' , { } ) path = bits [ 1 ] if ( ( path [ 0 ] in ( '"' , "'" ) ) and ( path [ ( - 1 ) ] == path [ 0 ] ) ) : return ConstantIncludeNode ( path [ 1 : ( - 1 ) ] , extra_context = namemap , isolated_context = isolated_context ) return IncludeNode ( parser . compile_filter ( bits [ 1 ] ) , extra_context = namemap , isolated_context = isolated_context )
loads a template and renders it with the current context .