Lines Matching refs:node
2 some node tree helper functions used by the parser and compiler in order
49 """Raised if the node could not perform a requested action."""
92 def get_eval_context(node: "Node", ctx: t.Optional[EvalContext]) -> EvalContext:
94 if node.environment is None:
96 "if no eval context is passed, the node must have an"
99 return EvalContext(node.environment)
110 - :class:`Template`: the outermost wrapper node
114 positional arguments, attributes as keyword arguments. Each node has
115 two attributes: `lineno` (the line number of the node) and `environment`.
172 """Iterates over all direct child nodes of the node. This iterates
185 """Find the first node of a given type. If no such node exists the
205 """Reset the context of a node and all child nodes. Per default the
212 node = todo.popleft()
213 if "ctx" in node.fields:
214 node.ctx = ctx # type: ignore
215 todo.extend(node.iter_child_nodes())
219 """Set the line numbers of the node and children."""
222 node = todo.popleft()
223 if "lineno" in node.attributes:
224 if node.lineno is None or override:
225 node.lineno = lineno
226 todo.extend(node.iter_child_nodes())
233 node = todo.popleft()
234 node.environment = environment
235 todo.extend(node.iter_child_nodes())
251 def _dump(node: t.Union[Node, t.Any]) -> None:
252 if not isinstance(node, Node):
253 buf.append(repr(node))
256 buf.append(f"nodes.{type(node).__name__}(")
257 if not node.fields:
260 for idx, field in enumerate(node.fields):
263 value = getattr(node, field)
281 """Base node for all statements."""
293 """Node that represents a template. This must be the outermost node that
302 """A node that holds multiple expressions which are then printed out.
321 `else` block. If no else node exists it has to be an empty list.
360 the unnamed macro as `caller` argument this node holds.
379 """Specific node for with statements. In older versions of Jinja the
380 with statement was implemented on the base of the `Scope` node instead.
392 """A node that represents a block.
406 """A node that represents the include tag."""
415 """A node that represents the import tag."""
424 """A node that represents the from import tag. It's important to not
429 problem for regular Jinja code, but if this node is used in an extension
444 fields = ("node",)
445 node: Node
451 fields = ("target", "node")
453 node: Node
484 """Check if it's possible to assign something to this node."""
516 fields = ("node",)
517 node: Expr
532 return f(self.node.as_const(eval_ctx))
539 The `ctx` of the node can be one of the following values:
565 # which goes through a `Name` node.
576 """All constant values. The parser will return this node for simple
717 node: t.Union["_FilterTestCommon", "Call"], eval_ctx: t.Optional[EvalContext]
719 args = [x.as_const(eval_ctx) for x in node.args]
720 kwargs = dict(x.as_const(eval_ctx) for x in node.kwargs)
722 if node.dyn_args is not None:
724 args.extend(node.dyn_args.as_const(eval_ctx))
728 if node.dyn_kwargs is not None:
730 kwargs.update(node.dyn_kwargs.as_const(eval_ctx))
738 fields = ("node", "name", "args", "kwargs", "dyn_args", "dyn_kwargs")
739 node: Expr
772 args.insert(0, self.node.as_const(eval_ctx))
789 If ``node`` is ``None``, the filter is being used in a filter block
793 node: t.Optional[Expr] # type: ignore
796 if self.node is None:
818 and `dyn_kwargs` has to be either `None` or a node that is used as
819 node for dynamic positional (``*args``) or keyword (``**kwargs``)
823 fields = ("node", "args", "kwargs", "dyn_args", "dyn_kwargs")
824 node: Expr
834 fields = ("node", "arg", "ctx")
835 node: Expr
847 self.node.as_const(eval_ctx), self.arg.as_const(eval_ctx)
858 fields = ("node", "attr", "ctx")
859 node: Expr
870 return eval_ctx.environment.getattr(self.node.as_const(eval_ctx), self.attr)
946 """Multiplies the left with the right node."""
952 """Divides the left by the right node."""
958 """Divides the left by the right node and converts the
966 """Add the left to the right node."""
972 """Subtract the right from the left node."""
1043 This node is usually constructed by calling the
1053 """If created with an import name the import name is returned on node
1116 :class:`Name` node, with a ``'load'`` ctx and will return the
1200 raise TypeError("can't create custom node types")