+ 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('"container" template tag option "references" requires an argument specifying a content type')
+ except ValueError:
+ raise template.TemplateSyntaxError('"container" template tag option "references" requires an argument of the form app_label.model (see django.contrib.contenttypes)')
+ except ObjectDoesNotExist:
+ raise template.TemplateSyntaxError('"container" template tag option "references" requires an argument of the form app_label.model which refers to an installed content type (see django.contrib.contenttypes)')
+ elif option_token == 'as':
+ try:
+ as_var = remaining_tokens.pop(0)
+ except IndexError:
+ raise template.TemplateSyntaxError('"container" template tag option "as" requires an argument specifying a variable name')
+ if references and not as_var:
+ raise template.TemplateSyntaxError('"container" template tags using "references" option require additional use of the "as" option specifying a variable name')
+ return ContainerNode(name, references, as_var)