@register.tag
def membersof(parser, token):
	"""
	Given a collection and a content type, sets the results of :meth:`collection.members.with_model <.CollectionMemberManager.with_model>` as a variable in the context.
	
	Usage::
	
		{% membersof <collection> with <app_label>.<model_name> as <var> %}
	
	"""
	params=token.split_contents()
	tag = params[0]
	
	if len(params) < 6:
		raise template.TemplateSyntaxError('"%s" template tag requires six parameters' % tag)
		
	if params[2] != 'with':
		raise template.TemplateSyntaxError('"%s" template tag requires the third parameter to be "with"' % tag)
	
	try:
		app_label, model = params[3].strip('"').split('.')
		ct = ContentType.objects.get_by_natural_key(app_label, model)
	except __HOLE__:
		raise template.TemplateSyntaxError('"%s" template tag option "with" requires an argument of the form app_label.model (see django.contrib.contenttypes)' % tag)
	except ContentType.DoesNotExist:
		raise template.TemplateSyntaxError('"%s" template tag option "with" requires an argument of the form app_label.model which refers to an installed content type (see django.contrib.contenttypes)' % tag)
		
	if params[4] != 'as':
		raise template.TemplateSyntaxError('"%s" template tag requires the fifth parameter to be "as"' % tag)
	
	return MembersofNode(collection=params[1], model=ct.model_class(), as_var=params[5])
dataset/ETHPy150Open ithinksw/philo/philo/templatetags/collections.py/membersof