+ if len(params) > 2:
+ remaining_tokens = params[2:]
+ while remaining_tokens:
+ option_token = remaining_tokens.pop(0)
+ if option_token == 'references':
+ try:
+ app_label, model = remaining_tokens.pop(0).strip('"').split('.')
+ references = ContentType.objects.get(app_label=app_label, model=model)
+ except IndexError:
+ raise template.TemplateSyntaxError('"%s" template tag option "references" requires an argument specifying a content type' % tag)
+ except ValueError:
+ raise template.TemplateSyntaxError('"%s" template tag option "references" requires an argument of the form app_label.model (see django.contrib.contenttypes)' % tag)
+ except ObjectDoesNotExist:
+ raise template.TemplateSyntaxError('"%s" template tag option "references" requires an argument of the form app_label.model which refers to an installed content type (see django.contrib.contenttypes)' % tag)
+ elif option_token == 'as':
+ try:
+ as_var = remaining_tokens.pop(0)
+ except IndexError:
+ raise template.TemplateSyntaxError('"%s" template tag option "as" requires an argument specifying a variable name' % tag)
+ if references and not as_var:
+ raise template.TemplateSyntaxError('"%s" template tags using "references" option require additional use of the "as" option specifying a variable name' % tag)
+ if tag == 'container':
+ return ContainerNode(name, references, as_var)
+
+ nodelist_main = parser.parse(('empty','endblockcontainer',))
+ token = parser.next_token()
+
+ if token.contents == 'empty':
+ nodelist_empty = parser.parse(('endblockcontainer',))
+ parser.delete_first_token()
+ else:
+ nodelist_empty = None
+ return ContainerNode(name, references, as_var, nodelist_main, nodelist_empty)
+