我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用jinja2.utils.concat()。
def visit_AssignBlock(self, node, frame): block_frame = frame.inner() block_frame.inspect(node.body) aliases = self.push_scope(block_frame) self.pull_locals(block_frame) self.buffer(block_frame) self.blockvisit(node.body, block_frame) self.pop_scope(aliases, block_frame) assignment_frame = self.make_assignment_frame(frame) self.newline(node) self.visit(node.target, assignment_frame) self.write(' = concat(%s)' % block_frame.buffer) self.export_assigned_vars(frame, assignment_frame) # -- Expression Visitors
def return_buffer_contents(self, frame, force_unescaped=False): """Return the buffer contents of the frame.""" if not force_unescaped: if frame.eval_ctx.volatile: self.writeline('if context.eval_ctx.autoescape:') self.indent() self.writeline('return Markup(concat(%s))' % frame.buffer) self.outdent() self.writeline('else:') self.indent() self.writeline('return concat(%s)' % frame.buffer) self.outdent() return elif frame.eval_ctx.autoescape: self.writeline('return Markup(concat(%s))' % frame.buffer) return self.writeline('return concat(%s)' % frame.buffer)
def visit_AssignBlock(self, node, frame): self.push_assign_tracking() block_frame = frame.inner() # This is a special case. Since a set block always captures we # will disable output checks. This way one can use set blocks # toplevel even in extended templates. block_frame.require_output_check = False block_frame.symbols.analyze_node(node) self.enter_frame(block_frame) self.buffer(block_frame) self.blockvisit(node.body, block_frame) self.newline(node) self.visit(node.target, frame) self.write(' = (Markup if context.eval_ctx.autoescape ' 'else identity)(concat(%s))' % block_frame.buffer) self.pop_assign_tracking(frame) self.leave_frame(block_frame) # -- Expression Visitors