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)
评论列表
文章目录