jinja2.nodes

This module implements additional nodes derived from the ast base node.

It also provides some node tree helper functions like in_lineno and get_nodes used by the parser and translator in order to normalize python and jinja nodes.

copyright:
  1. 2010 by the Jinja Team.
license:

BSD, see LICENSE for more details.

Functions

get_eval_context(node, ctx)
with_metaclass(meta, *bases)

Classes

Add(*fields, **attributes) Add the left to the right node.
And(*fields, **attributes) Short circuited AND.
Assign(*fields, **attributes) Assigns an expression to a target.
AssignBlock(*fields, **attributes) Assigns a block to a target.
BinExpr(*fields, **attributes) Baseclass for all binary expressions.
Block(*fields, **attributes) A node that represents a block.
Break(*fields, **attributes) Break a loop.
Call(*fields, **attributes) Calls an expression.
CallBlock(*fields, **attributes) Like a macro without a name but a call instead.
Compare(*fields, **attributes) Compares an expression with some other expressions.
Concat(*fields, **attributes) Concatenates the list of expressions provided after converting them to unicode.
CondExpr(*fields, **attributes) A conditional expression (inline if expression).
Const(*fields, **attributes) All constant values.
ContextReference(*fields, **attributes) Returns the current template context.
Continue(*fields, **attributes) Continue a loop.
Dict(*fields, **attributes) Any dict literal such as {1: 2, 3: 4}.
Div(*fields, **attributes) Divides the left by the right node.
EnvironmentAttribute(*fields, **attributes) Loads an attribute from the environment object.
EvalContext(environment[, template_name]) Holds evaluation time information.
EvalContextModifier(*fields, **attributes) Modifies the eval context.
Expr(*fields, **attributes) Baseclass for all expressions.
ExprStmt(*fields, **attributes) A statement that evaluates an expression and discards the result.
Extends(*fields, **attributes) Represents an extends statement.
ExtensionAttribute(*fields, **attributes) Returns the attribute of an extension bound to the environment.
Filter(*fields, **attributes) This node applies a filter on an expression.
FilterBlock(*fields, **attributes) Node for filter sections.
FloorDiv(*fields, **attributes) Divides the left by the right node and truncates conver the result into an integer by truncating.
For(*fields, **attributes) The for loop.
FromImport(*fields, **attributes) A node that represents the from import tag.
Getattr(*fields, **attributes) Get an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute.
Getitem(*fields, **attributes) Get an attribute or item from an expression and prefer the item.
Helper(*fields, **attributes) Nodes that exist in a specific context only.
If(*fields, **attributes) If test is true, body is rendered, else else_.
Import(*fields, **attributes) A node that represents the import tag.
ImportedName(*fields, **attributes) If created with an import name the import name is returned on node access.
Include(*fields, **attributes) A node that represents the include tag.
InternalName() An internal name in the compiler.
Keyword(*fields, **attributes) A key, value pair for keyword arguments where key is a string.
List(*fields, **attributes) Any list literal such as [1, 2, 3]
Literal(*fields, **attributes) Baseclass for literals.
Macro(*fields, **attributes) A macro definition.
MarkSafe(*fields, **attributes) Mark the wrapped expression as safe (wrap it as Markup).
MarkSafeIfAutoescape(*fields, **attributes) Mark the wrapped expression as safe (wrap it as Markup) but only if autoescaping is active.
Markup Marks a string as being safe for inclusion in HTML/XML output without needing to be escaped.
Mod(*fields, **attributes) Left modulo right.
Mul(*fields, **attributes) Multiplies the left with the right node.
Name(*fields, **attributes) Looks up a name or stores a value in a name.
Neg(*fields, **attributes) Make the expression negative.
Node(*fields, **attributes) Baseclass for all Jinja2 nodes.
NodeType A metaclass for nodes that handles the field and attribute inheritance.
Not(*fields, **attributes) Negate the expression.
Operand(*fields, **attributes) Holds an operator and an expression.
Or(*fields, **attributes) Short circuited OR.
Output(*fields, **attributes) A node that holds multiple expressions which are then printed out.
Pair(*fields, **attributes) A key, value pair for dicts.
Pos(*fields, **attributes) Make the expression positive (noop for most expressions)
Pow(*fields, **attributes) Left to the power of right.
Scope(*fields, **attributes) An artificial scope.
ScopedEvalContextModifier(*fields, **attributes) Modifies the eval context and reverts it later.
Slice(*fields, **attributes) Represents a slice object.
Stmt(*fields, **attributes) Base node for all statements.
Sub(*fields, **attributes) Subtract the right from the left node.
Template(*fields, **attributes) Node that represents a template.
TemplateData(*fields, **attributes) A constant template string.
Test(*fields, **attributes) Applies a test on an expression.
Tuple(*fields, **attributes) For loop unpacking and some other things like multiple arguments for subscripts.
UnaryExpr(*fields, **attributes) Baseclass for all unary expressions.
deque deque([iterable[, maxlen]]) –> deque object
izip izip(iter1 [,iter2 [...]]) –> izip object
text_type alias of unicode

Exceptions

Impossible Raised if the node could not perform a requested action.