def do_relations_for_object(parser, token):
    """
    Retrieves a list of ``Relations`` for a given object
    
    Useage::
        
        {% relations_for_object [object] as [varname] %}
        {% relations_for_object [object] as [varname] with [type=TYPE]}
        
    Example::
    
        {% relations_for_object story as story_relations %}
        {% relations_for_object story as story_relations with type=Quotation %}
        
    """
    bits = token.contents.split()
    if len(bits) < 4 or len(bits) > 6:
        raise TemplateSyntaxError(_('%s tag requires at least three arguments and at most six arguments') % bits[0])
    if bits[2] != 'as':
        raise TemplateSyntaxError(_("Second argument for %s tag must be 'as'") % bits[0])
        
    if len(bits) > 4:
        if bits[4] != "with":
            raise TemplateSyntacError(_("Fouth argument for %s tag must be 'with'") % bits[0])
        
        if len(bits[5].split("=")) == 2 and bits[5].split("=")[0] == 'type':
             return RelationsForObjectNode(bits[1], bits[3], bits[5].split("=")[1])
        else:
            raise TemplateSyntacError(_("Last argument for %s tag must be in the format type=[TYPE]") % bits[0])
    return RelationsForObjectNode(bits[1], bits[3])
dataset/ETHPy150Open callowayproject/django-supertagging/supertagging/templatetags/supertagging_tags.py/do_relations_for_object/original