@register.tag(name='get_annotations_for')
def do_get_annotations_for(parser, token):
    """Use like so: {% get_annotations_for object_list as var_name %}
    Note: objects in object_list must be of one ContentType!
    var_name is a dict that contains the id of every object in object_list as key.
    The value is another dict with two keys: "annotations" as a list of annotations and
    "form" as an annotation form instance
    """
    as_var = None
    try:
        contents = token.split_contents()
        instance_name = contents[1]
        if len(contents) >= 4 and contents[2] == "as":
            as_var = contents[3]

    except (ValueError, __HOLE__):
        raise template.TemplateSyntaxError, "Tag Syntax Error: %r object_list as var_name" % token.contents.split()[0]
    return InsertAnnotationNode(instance_name, as_var)
dataset/ETHPy150Open stefanw/django-annotatetext/annotatetext/templatetags/annotatetags.py/do_get_annotations_for