def do_get_content(parser, token):
    """Retrieve a Content object and insert it into the template's context.

    Example::

        {% get_content page_object "title" as content %}

    You can also use the slug of a page::

        {% get_content "my-page-slug" "title" as content %}

    Syntax::

        {% get_content page type [lang] as name %}

    :param page: the page object, slug or id
    :param type: content_type used by a placeholder
    :param name: name of the context variable to store the content in
    :param lang: the wanted language
    """
    bits = token.split_contents()
    if not 5 <= len(bits) <= 6:
        raise TemplateSyntaxError('%r expects 4 or 5 arguments' % bits[0])
    if bits[-2] != 'as':
        raise TemplateSyntaxError(
            '%r expects "as" as the second last argument' % bits[0])
    page = parser.compile_filter(bits[1])
    content_type = parser.compile_filter(bits[2])
    varname = bits[-1]
    lang = None
    lang_filter = None
    if len(bits) == 6:
        lang = bits[3]
    else:
        lang_filter = parser.compile_filter("lang")
    return GetContentNode(page, content_type, varname, lang, lang_filter)
dataset/ETHPy150Open batiste/django-page-cms/pages/templatetags/pages_tags.py/do_get_content/original