@register.tag
def get_category_drilldown(parser, token):
    """
    Retrieves the specified category, its ancestors and its immediate children
    as an iterable.

    Syntax::

        {% get_category_drilldown "category name" [using "app.Model"] as varname %}

    Example::

        {% get_category_drilldown "/Grandparent/Parent" [using "app.Model"] as family %}

    or ::

        {% get_category_drilldown category_obj as family %}

    Sets family to::

        Grandparent, Parent, Child 1, Child 2, Child n
    """
    bits = token.split_contents()
    error_str = '%(tagname)s tag should be in the format {%% %(tagname)s ' \
                '"category name" [using "app.Model"] as varname %%} or ' \
                '{%% %(tagname)s category_obj as varname %%}.'
    if len(bits) == 4:
        if bits[2] != 'as':
            raise template.TemplateSyntaxError(error_str % {'tagname': bits[0]})
        if bits[2] == 'as':
            varname = bits[3].strip("'\"")
            model = "categories.category"
    if len(bits) == 6:
        if bits[2] not in ('using', 'as') or bits[4] not in ('using', 'as'):
            raise template.TemplateSyntaxError(error_str % {'tagname': bits[0]})
        if bits[2] == 'as':
            varname = bits[3].strip("'\"")
            model = bits[5].strip("'\"")
        if bits[2] == 'using':
            varname = bits[5].strip("'\"")
            model = bits[3].strip("'\"")
    category = FilterExpression(bits[1], parser)
    return CategoryDrillDownNode(category, varname, model)
dataset/ETHPy150Open callowayproject/django-categories/categories/templatetags/category_tags.py/get_category_drilldown/original