我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用jinja2.nodes.Extends()。
def parse_extends(self): node = nodes.Extends(lineno=next(self.stream).lineno) node.template = self.parse_expression() return node
def parse(self, parser): lineno = next(parser.stream).lineno node = nodes.Extends(lineno) template_path = parser.filename # find where in the search path this template is from index = 0 if not hasattr(self, 'searchpath'): return node for searchpath in self.searchpath: if template_path.startswith(searchpath): break index += 1 # get filename from full path filename = template_path[len(searchpath) + 1:] # Providing template path violently deprecated if parser.stream.current.type != 'block_end': provided_template = parser.parse_expression().value if provided_template != filename: raise Exception('ckan_extends tag wrong path %s in %s' % (provided_template, template_path)) else: log.critical('Remove path from ckan_extend tag in %s' % template_path) # provide our magic format # format is *<search path parent index>*<template name> magic_filename = '*' + str(index) + '*' + filename # set template node.template = nodes.Const(magic_filename) return node