示例#1
0
def do_include_raw(parser, token):
    """
    Performs a template include without parsing the context, just dumps
    the template in.
    Source: http://djangosnippets.org/snippets/1684/
    """
    bits = token.split_contents()
    if len(bits) != 2:
        raise template.TemplateSyntaxError(
            "%r tag takes one argument: the name of the template "
            "to be included" % bits[0])

    template_name = bits[1]
    if (template_name[0] in ('"', "'")
            and template_name[-1] == template_name[0]):
        template_name = template_name[1:-1]

    source, __ = get_template_source(template_name)

    return template.base.TextNode(source)
示例#2
0
文件: store_tags.py 项目: Yelp/pootle
def do_include_raw(parser, token):
    """
    Performs a template include without parsing the context, just dumps
    the template in.
    Source: http://djangosnippets.org/snippets/1684/
    """
    bits = token.split_contents()
    if len(bits) != 2:
        raise template.TemplateSyntaxError(
            "%r tag takes one argument: the name of the template "
            "to be included" % bits[0]
        )

    template_name = bits[1]
    if template_name[0] in ('"', "'") and template_name[-1] == template_name[0]:
        template_name = template_name[1:-1]

    source, path = get_template_source(template_name)

    return template.TextNode(source)