3 C\x @svdZddlZddlZddlmZddlmZddlmZm Z m Z m Z ej ej fZejejejejejejejdZejejejdZejejejejejej dd d d d Z!Gd d d e"Z#Gddde$Z%Gddde&Z'ddZ(Gddde e%e&Z)Gddde)Z*Gddde)Z+Gddde)Z,Gddde*Z-Gddde*Z.Gd d!d!e*Z/Gd"d#d#e*Z0Gd$d%d%e*Z1Gd&d'd'e*Z2Gd(d)d)e*Z3Gd*d+d+e*Z4Gd,d-d-e*Z5Gd.d/d/e*Z6Gd0d1d1e*Z7Gd2d3d3e*Z8Gd4d5d5e*Z9Gd6d7d7e*Z:Gd8d9d9e*Z;Gd:d;d;e)Zd?d?e<Z>Gd@dAdAe<Z?GdBdCdCe<Z@GdDdEdEe<ZAGdFdGdGeAZBGdHdIdIeAZCGdJdKdKeAZDGdLdMdMeAZEGdNdOdOeAZFGdPdQdQe+ZGGdRdSdSe+ZHGdTdUdUe<ZIdVdWZJGdXdYdYe<ZKGdZd[d[e<ZLGd\d]d]e<ZMGd^d_d_e<ZNGd`dadae<ZOGdbdcdce<ZPGdddedee<ZQGdfdgdge<ZRGdhdidie+ZSeSjdjdkjTeUdldmeVeeVeBeVe!BD7_Gdndodoe=ZWGdpdqdqe=ZXGdrdsdse=ZYGdtdudue=ZZGdvdwdwe=Z[Gdxdydye=Z\Gdzd{d{e=Z]Gd|d}d}e=Z^Gd~dde=Z_Gddde>Z`Gddde>ZaGddde>ZbGddde<ZcGddde<ZdGddde<ZeGddde<ZfGddde<ZgGddde<ZhGddde<ZiGddde*ZjGddde*ZkGddde*ZlGddde*ZmGddde*ZnGdddenZoddZpeqepe%_r[pdS)a} 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: (c) 2017 by the Jinja Team. :license: BSD, see LICENSE for more details. N)deque)Markup)izipwith_metaclass text_typePY2)*/z//z**%+-)notr r cCs||kS)N)abrrd/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/jinja2/jinja2/nodes.py2srcCs||kS)Nr)rrrrrr3s)eqnegtZgteqltZlteqinnotinc@seZdZdZdS) Impossiblez8Raised if the node could not perform a requested action.N)__name__ __module__ __qualname____doc__rrrrr7src@seZdZdZddZdS)NodeTypezA metaclass for nodes that handles the field and attribute inheritance. fields and attributes from the parent class are automatically forwarded to the child.cCsxtd D]l}g}|jt|d|f|j|j|ft|dksJtdt|tt|ksftdt|||<qW|jddtj ||||S) Nfields attributesrz multiple inheritance not allowedzlayout conflictabstractF)rr ) extendgetattrgetlenAssertionErrorsettuple setdefaulttype__new__)clsnamebasesdattrZstoragerrrr,@s  zNodeType.__new__N)rrrrr,rrrrr;src@s*eZdZdZd ddZddZddZdS) EvalContextzcHolds evaluation time information. Custom attributes can be attached to it in extensions. NcCs0||_t|jr|j||_n|j|_d|_dS)NF) environmentcallable autoescapevolatile)selfr3Z template_namerrr__init__Qs  zEvalContext.__init__cCs |jjS)N)__dict__copy)r7rrrsaveYszEvalContext.savecCs|jj|jj|dS)N)r9clearupdate)r7oldrrrrevert\s zEvalContext.revert)N)rrrrr8r;r?rrrrr2Ls r2cCs(|dkr$|jdkrtdt|jS|S)NzIif no eval context is passed, the node must have an attached environment.)r3 RuntimeErrorr2)nodectxrrrget_eval_contextas   rCc@seZdZdZfZdZdZddZd dd Zd!d d Z d d Z ddZ ddZ d"ddZ ddZddZddZejZddZddZdS)#NodeaBaseclass for all Jinja2 nodes. There are a number of nodes available of different types. There are four major types: - :class:`Stmt`: statements - :class:`Expr`: expressions - :class:`Helper`: helper nodes - :class:`Template`: the outermost wrapper node All nodes have fields and attributes. Fields may be other nodes, lists, or arbitrary values. Fields are passed to the constructor as regular positional arguments, attributes as keyword arguments. Each node has two attributes: `lineno` (the line number of the node) and `environment`. The `environment` attribute is set at the end of the parsing process for all nodes automatically. linenor3TcOs|jrtd|rt|t|jkrh|js:td|jjtd|jjt|jt|jdkr^dp`dfx$t|j|D]\}}t|||qvWx"|jD]}t|||j |dqW|rtdt t |dS)Nz#abstract nodes are not instanciablez%r takes 0 argumentsz%r takes 0 or %d argument%sr!szunknown attribute %r) r" TypeErrorr&r __class__rrsetattrr popnextiter)r7rr r.argr1rrrr8s$  z Node.__init__Nc csvxp|jD]f}||kodknsD|dk r4||ksD|dk r||kry|t||fVWqtk rlYqXqWdS)aZThis method iterates over all fields that are defined and yields ``(key, value)`` tuples. Per default all fields are returned, but it's possible to limit that to some fields by providing the `only` parameter or to exclude some using the `exclude` parameter. Both should be sets or tuples of field names. N)rr$AttributeError)r7excludeonlyr.rrr iter_fieldss zNode.iter_fieldsccsXxR|j||D]B\}}t|tr@x.|D]}t|tr&|Vq&Wqt|tr|VqWdS)zIterates over all direct child nodes of the node. This iterates over all fields and yields the values of they are nodes. If the value of a field is a list all the nodes in that list are returned. N)rR isinstancelistrD)r7rPrQfielditemnrrriter_child_nodess     zNode.iter_child_nodescCsx|j|D]}|SWdS)ziFind the first node of a given type. If no such node exists the return value is `None`. N)find_all)r7 node_typeresultrrrfindsz Node.findccs@x:|jD].}t||r|Vx|j|D] }|Vq*Wq WdS)zFind all the nodes of a given type. If the type is a tuple, the check is performed for any of the tuple items. N)rXrSrY)r7rZchildr[rrrrYs  z Node.find_allcCs>t|g}x.|r8|j}d|jkr(||_|j|jq W|S)aReset the context of a node and all child nodes. Per default the parser will all generate nodes that have a 'load' context as it's the most common one. This method is used in the parser to set assignment targets and other nodes to a store context. rB)rpopleftrrBr#rX)r7rBtodorArrrset_ctxs  z Node.set_ctxFcCsLt|g}x<|rF|j}d|jkr6|jdks0|r6||_|j|jq W|S)z.Set the line numbers of the node and children.rEN)rr^r rEr#rX)r7rEoverrider_rArrr set_linenos  zNode.set_linenocCs4t|g}x$|r.|j}||_|j|jq W|S)z"Set the environment for all nodes.)rr^r3r#rX)r7r3r_rArrrset_environments  zNode.set_environmentcCs(t|t|ko&t|jt|jkS)N)r+r)rR)r7otherrrr__eq__sz Node.__eq__cCs |j| S)N)re)r7rdrrr__ne__sz Node.__ne__cs&djjdjfddjDfS)Nz%s(%s)z, c3s"|]}d|t|dfVqdS)z%s=%rN)r$).0rN)r7rr sz Node.__repr__..)rIrjoinr)r7r)r7r__repr__sz Node.__repr__cs$fddg|djS)Ncst|tsjt|dSjd|jj|jsBjddSxt|jD]t\}}|rdjdt||}t|t rjdx*t|D]\}}|rjd|qWjdqN|qNWjddS)Nz nodes.%s()z, []) rSrDappendreprrIrr enumerater$rT)rAidxrUvaluerV)_dumpbufrrrss(          zNode.dump.._dumprG)ri)r7r)rsrtrdumpsz Node.dump)rEr3)NN)NN)F)rrrrrr r"r8rRrXr\rYr`rbrcrerfobject__hash__rjrurrrrrDks"     rDc@seZdZdZdZdS)StmtzBase node for all statements.TN)rrrrr"rrrrrxsrxc@seZdZdZdZdS)Helperz,Nodes that exist in a specific context only.TN)rrrrr"rrrrrysryc@seZdZdZdZdS)TemplatezjNode that represents a template. This must be the outermost node that is passed to the compiler. bodyN)r{)rrrrrrrrrrzsrzc@seZdZdZdZdS)OutputzA node that holds multiple expressions which are then printed out. This is used both for the `print` statement and the regular template data. nodesN)r})rrrrrrrrrr|$sr|c@seZdZdZdZdS)Extendsz Represents an extends statement.templateN)r)rrrrrrrrrr~+sr~c@seZdZdZd ZdS) ForaxThe for loop. `target` is the target for the iteration (usually a :class:`Name` or :class:`Tuple`), `iter` the iterable. `body` is a list of nodes that are used as loop-body, and `else_` a list of nodes for the `else` block. If no else node exists it has to be an empty list. For filtered nodes an expression can be stored as `test`, otherwise `None`. targetrMr{else_test recursiveN)rrMr{rrr)rrrrrrrrrr0src@seZdZdZdZdS)Ifz4If `test` is true, `body` is rendered, else `else_`.rr{elif_rN)rr{rr)rrrrrrrrrr;src@seZdZdZdZdS)MacrozA macro definition. `name` is the name of the macro, `args` a list of arguments and `defaults` a list of defaults if there are any. `body` is a list of nodes for the macro body. r.argsdefaultsr{N)r.rrr{)rrrrrrrrrr@src@seZdZdZdZdS) CallBlockzLike a macro without a name but a call instead. `call` is called with the unnamed macro as `caller` argument this node holds. callrrr{N)rrrr{)rrrrrrrrrrHsrc@seZdZdZdZdS) FilterBlockzNode for filter sections.r{filterN)r{r)rrrrrrrrrrOsrc@seZdZdZdZdS)WithzSpecific node for with statements. In older versions of Jinja the with statement was implemented on the base of the `Scope` node instead. .. versionadded:: 2.9.3 targetsvaluesr{N)rrr{)rrrrrrrrrrTsrc@seZdZdZdZdS)BlockzA node that represents a block.r.r{scopedN)r.r{r)rrrrrrrrrr]src@seZdZdZdZdS)Includez'A node that represents the include tag.r with_contextignore_missingN)rrr)rrrrrrrrrrbsrc@seZdZdZdZdS)Importz&A node that represents the import tag.rrrN)rrr)rrrrrrrrrrgsrc@seZdZdZdZdS) FromImportaA node that represents the from import tag. It's important to not pass unsafe names to the name attribute. The compiler translates the attribute lookups directly into getattr calls and does *not* use the subscript callback of the interface. As exported variables may not start with double underscores (which the parser asserts) this is not a problem for regular Jinja code, but if this node is used in an extension extra care must be taken. The list of names may contain tuples if aliases are wanted. rnamesrN)rrr)rrrrrrrrrrls rc@seZdZdZdZdS)ExprStmtzAA statement that evaluates an expression and discards the result.rAN)rA)rrrrrrrrrrzsrc@seZdZdZdZdS)Assignz"Assigns an expression to a target.rrAN)rrA)rrrrrrrrrrsrc@seZdZdZdZdS) AssignBlockzAssigns a block to a target.rrr{N)rrr{)rrrrrrrrrrsrc@s&eZdZdZdZdddZddZdS) ExprzBaseclass for all expressions.TNcCs tdS)anReturn the value of the expression as constant or raise :exc:`Impossible` if this was not possible. An :class:`EvalContext` can be provided, if none is given a default context is created which requires the nodes to have an attached environment. .. versionchanged:: 2.4 the `eval_ctx` parameter was added. N)r)r7eval_ctxrrras_consts z Expr.as_constcCsdS)z8Check if it's possible to assign something to this node.Fr)r7rrr can_assignszExpr.can_assign)N)rrrrr"rrrrrrrs rc@s&eZdZdZdZdZdZd ddZdS) BinExprz%Baseclass for all binary expressions.leftrightNTc Csjt||}|jjr&|j|jjkr&tt|j}y||jj||j j|St k rdtYnXdS)N) rCr3 sandboxedoperatorZintercepted_binopsr_binop_to_funcrrr Exception)r7rfrrrrs  zBinExpr.as_const)rr)N)rrrrrrr"rrrrrrs rc@s&eZdZdZdZdZdZdddZdS) UnaryExprz$Baseclass for all unary expressions.rANTc Cs`t||}|jjr&|j|jjkr&tt|j}y||jj|St k rZtYnXdS)N) rCr3rrZintercepted_unopsr _uaop_to_funcrArr)r7rrrrrrs  zUnaryExpr.as_const)rA)N)rrrrrrr"rrrrrrs rc@seZdZdZdZddZdS)Namea Looks up a name or stores a value in a name. The `ctx` of the node can be one of the following values: - `store`: store a value in the name - `load`: load that name - `param`: like `store` but if the name was defined as function parameter. r.rBcCs |jdkS)NtruefalsenoneTrueFalseNone)rrrrrr)r.)r7rrrrszName.can_assignN)r.rB)rrrrrrrrrrrsrc@seZdZdZdZddZdS)NSRefz)Reference to a namespace value assignmentr.r1cCsdS)NTr)r7rrrrszNSRef.can_assignN)r.r1)rrrrrrrrrrrsrc@seZdZdZdZdS)LiteralzBaseclass for literals.TN)rrrrr"rrrrrsrc@s,eZdZdZdZd ddZed ddZdS) ConstaAll constant values. The parser will return this node for simple constants such as ``42`` or ``"foo"`` but it can be used to store more complex values such as lists too. Only constants with a safe representation (objects where ``eval(repr(x)) == x`` is true). rrNc CsJ|j}trFt|tkrF|jjdrFy|jd}Wntk rDYnX|S)Nzcompiler.ascii_strascii)rrrr+rr3Zpoliciesencode UnicodeError)r7rrvrrrrs zConst.as_constcCs(ddlm}||st||||dS)zReturn a const object if the value is representable as constant value in the generated code, otherwise it will raise an `Impossible` exception. r!) has_safe_repr)rEr3)compilerrr)r-rrrEr3rrrrfrom_untrusteds zConst.from_untrusted)rr)N)NN)rrrrrr classmethodrrrrrrs  rc@seZdZdZdZdddZdS) TemplateDatazA constant template string.dataNcCs,t||}|jrt|jr&t|jS|jS)N)rCr6rr5rr)r7rrrrrs   zTemplateData.as_const)r)N)rrrrrrrrrrrsrc@s&eZdZdZd Zd ddZddZdS) TuplezFor loop unpacking and some other things like multiple arguments for subscripts. Like for :class:`Name` `ctx` specifies if the tuple is used for loading the names or storing. itemsrBNcs"t|tfdd|jDS)Nc3s|]}|jVqdS)N)r)rgx)rrrrhsz!Tuple.as_const..)rCr)r)r7rr)rrrs zTuple.as_constcCs x|jD]}|jsdSqWdS)NFT)rr)r7rVrrrrs zTuple.can_assign)rrB)N)rrrrrrrrrrrrs rc@seZdZdZdZdddZdS)Listz&Any list literal such as ``[1, 2, 3]``rNcst|fdd|jDS)Ncsg|]}|jqSr)r)rgr)rrr (sz!List.as_const..)rCr)r7rr)rrr&s z List.as_const)r)N)rrrrrrrrrrr"src@seZdZdZdZdddZdS)DictzeAny dict literal such as ``{1: 2, 3: 4}``. The items must be a list of :class:`Pair` nodes. rNcs"t|tfdd|jDS)Nc3s|]}|jVqdS)N)r)rgr)rrrrh3sz Dict.as_const..)rCdictr)r7rr)rrr1s z Dict.as_const)r)N)rrrrrrrrrrr+src@seZdZdZdZdddZdS) PairzA key, value pair for dicts.keyrrNcCs"t||}|jj||jj|fS)N)rCrrrr)r7rrrrr:s z Pair.as_const)rrr)N)rrrrrrrrrrr6src@seZdZdZdZdddZdS) Keywordz>A key, value pair for keyword arguments where key is a string.rrrNcCst||}|j|jj|fS)N)rCrrrr)r7rrrrrCs zKeyword.as_const)rrr)N)rrrrrrrrrrr?src@seZdZdZdZd ddZdS) CondExprzZA conditional expression (inline if expression). (``{{ foo if bar else baz }}``) rexpr1expr2NcCs>t||}|jj|r"|jj|S|jdkr2t|jj|S)N)rCrrrrr)r7rrrrrNs     zCondExpr.as_const)rrr)N)rrrrrrrrrrrHsrcsfdd|jD}tfdd|jD}|jdk rhy|j|jjWntk rftYnX|jdk ry|j |jjWntk rtYnX||fS)Ncsg|]}|jqSr)r)rgr)rrrr[sz!args_as_const..c3s|]}|jVqdS)N)r)rgr)rrrrh\sz args_as_const..) rrkwargsdyn_argsr#rrr dyn_kwargsr=)rArrrr)rr args_as_constZs    rc@seZdZdZd Zd d d ZdS) FilteraThis node applies a filter on an expression. `name` is the name of the filter, the rest of the fields are the same as for :class:`Call`. If the `node` of a filter is `None` the contents of the last buffer are filtered. Buffers are created by macros and filter blocks. rAr.rrrrNc Cst||}|js|jdkr t|jjj|j}|dksDt|ddrJt|jj rdt|ddrdtt ||\}}|j d|jj |t|ddr|j d|nt|ddr|j d|jy |||St k rtYnXdS)NZ contextfilterFZasyncfiltervariantrZevalcontextfilterZenvironmentfilter)rCr6rArr3filtersr%r.r$Zis_asyncrinsertrr)r7rZfilter_rrrrrrws&     zFilter.as_const)rAr.rrrr)N)rrrrrrrrrrrmsrc@seZdZdZd Zd d d ZdS) TestzApplies a test on an expression. `name` is the name of the test, the rest of the fields are the same as for :class:`Call`. rAr.rrrrNc Cst|jjj|j}|dkrtt||}t||\}}|jd|jj |y |||St k rntYnXdS)Nr) r3testsr%r.rrCrrrArr)r7rrrrrrrrs  z Test.as_const)rAr.rrrr)N)rrrrrrrrrrrsrc@seZdZdZdZdS) Calla/Calls an expression. `args` is a list of arguments, `kwargs` a list of keyword arguments (list of :class:`Keyword` nodes), and `dyn_args` and `dyn_kwargs` has to be either `None` or a node that is used as node for dynamic positional (``*args``) or keyword (``**kwargs``) arguments. rArrrrN)rArrrr)rrrrrrrrrrsrc@s&eZdZdZd Zd ddZdd ZdS) Getitemz@Get an attribute or item from an expression and prefer the item.rArNrBNc CsXt||}|jdkrty|jj|jj||jj|Stk rRtYnXdS)Nload) rCrBrr3getitemrArrNr)r7rrrrrs  zGetitem.as_constcCsdS)NFr)r7rrrrszGetitem.can_assign)rArNrB)N)rrrrrrrrrrrrs rc@s&eZdZdZd Zd ddZdd ZdS) GetattrznGet an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute. rAr1rBNc CsR|jdkrty"t||}|jj|jj||jStk rLtYnXdS)Nr) rBrrCr3r$rArr1r)r7rrrrrs  zGetattr.as_constcCsdS)NFr)r7rrrrszGetattr.can_assign)rAr1rB)N)rrrrrrrrrrrrs rc@seZdZdZdZd ddZdS) Slicez_Represents a slice object. This must only be used as argument for :class:`Subscript`. startstopstepNcs4t|fdd}t||j||j||jS)Ncs|dkr dS|jS)N)r)obj)rrrconstszSlice.as_const..const)rCslicerrr)r7rrr)rrrs  zSlice.as_const)rrr)N)rrrrrrrrrrrsrc@seZdZdZdZdddZdS)ConcatzXConcatenates the list of expressions provided after converting them to unicode. r}Ncs$t|djfdd|jDS)NrGc3s|]}t|jVqdS)N)rr)rgr)rrrrhsz"Concat.as_const..)rCrir})r7rr)rrrs zConcat.as_const)r})N)rrrrrrrrrrrsrc@seZdZdZdZdddZdS) CompareziCompares an expression with some other expressions. `ops` must be a list of :class:`Operand`\s. expropsNc Csnt||}|jj|}}y4x.|jD]$}|jj|}t|j||}|}q$WWntk rhtYnX|S)N)rCrrr_cmpop_to_funcoprr)r7rr[rrrZ new_valuerrrrs     zCompare.as_const)rr)N)rrrrrrrrrrrsrc@seZdZdZdZdS)Operandz$Holds an operator and an expression.rrN)rr)rrrrrrrrrrsrz( The following operators are available: z, ccs|]}d|VqdS)z``%s``Nr)rgrrrrrhsrhc@seZdZdZdZdS)Mulz(Multiplies the left with the right node.rN)rrrrrrrrrrsrc@seZdZdZdZdS)Divz#Divides the left by the right node.r N)rrrrrrrrrr src@seZdZdZdZdS)FloorDivzjDivides the left by the right node and truncates conver the result into an integer by truncating. z//N)rrrrrrrrrr%src@seZdZdZdZdS)AddzAdd the left to the right node.r N)rrrrrrrrrr,src@seZdZdZdZdS)Subz&Subtract the right from the left node.r N)rrrrrrrrrr1src@seZdZdZdZdS)ModzLeft modulo right.r N)rrrrrrrrrr6src@seZdZdZdZdS)PowzLeft to the power of right.z**N)rrrrrrrrrr;src@seZdZdZdZdddZdS)AndzShort circuited AND.andNcCs"t||}|jj|o |jj|S)N)rCrrr)r7rrrrrDs z And.as_const)N)rrrrrrrrrrr@src@seZdZdZdZdddZdS)OrzShort circuited OR.orNcCs"t||}|jj|p |jj|S)N)rCrrr)r7rrrrrMs z Or.as_const)N)rrrrrrrrrrrIsrc@seZdZdZdZdS)NotzNegate the expression.r N)rrrrrrrrrrRsrc@seZdZdZdZdS)NegzMake the expression negative.r N)rrrrrrrrrrWsrc@seZdZdZdZdS)Posz8Make the expression positive (noop for most expressions)r N)rrrrrrrrrr\src@seZdZdZdZdS)EnvironmentAttributezLoads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment. r.N)r.)rrrrrrrrrrdsrc@seZdZdZdZdS)ExtensionAttributezReturns the attribute of an extension bound to the environment. The identifier is the identifier of the :class:`Extension`. This node is usually constructed by calling the :meth:`~jinja2.ext.Extension.attr` method on an extension. identifierr.N)rr.)rrrrrrrrrrksrc@seZdZdZdZdS) ImportedNamea&If created with an import name the import name is returned on node access. For example ``ImportedName('cgi.escape')`` returns the `escape` function from the cgi module on evaluation. Imports are optimized by the compiler so there is no need to assign them to local variables. importnameN)r)rrrrrrrrrrusrc@seZdZdZdZddZdS) InternalNamea7An internal name in the compiler. You cannot create these nodes yourself but the parser provides a :meth:`~jinja2.parser.Parser.free_identifier` method that creates a new identifier for you. This identifier is not available from the template and is not threated specially by the compiler. r.cCs tddS)NzKCan't create internal names. Use the `free_identifier` method on a parser.)rH)r7rrrr8szInternalName.__init__N)r.)rrrrrr8rrrrr~src@seZdZdZdZdddZdS)MarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).rNcCst||}t|jj|S)N)rCrrr)r7rrrrrs zMarkSafe.as_const)r)N)rrrrrrrrrrrsrc@seZdZdZdZdddZdS)MarkSafeIfAutoescapezMark the wrapped expression as safe (wrap it as `Markup`) but only if autoescaping is active. .. versionadded:: 2.5 rNcCs4t||}|jrt|jj|}|jr0t|S|S)N)rCr6rrrr5r)r7rrrrrrs  zMarkSafeIfAutoescape.as_const)r)N)rrrrrrrrrrrsrc@seZdZdZdS)ContextReferencearReturns the current template context. It can be used like a :class:`Name` node, with a ``'load'`` ctx and will return the current :class:`~jinja2.runtime.Context` object. Here an example that assigns the current template name to a variable named `foo`:: Assign(Name('foo', ctx='store'), Getattr(ContextReference(), 'name')) N)rrrrrrrrrs rc@seZdZdZdS)ContinuezContinue a loop.N)rrrrrrrrrsrc@seZdZdZdS)Breakz Break a loop.N)rrrrrrrrrsrc@seZdZdZdZdS)ScopezAn artificial scope.r{N)r{)rrrrrrrrrrsrc@seZdZdZdZdS) OverlayScopeaAn overlay scope for extensions. This is a largely unoptimized scope that however can be used to introduce completely arbitrary variables into a sub scope from a dictionary or dictionary like object. The `context` field has to evaluate to a dictionary object. Example usage:: OverlayScope(context=self.call_method('get_context'), body=[...]) .. versionadded:: 2.10 contextr{N)rr{)rrrrrrrrrrs rc@seZdZdZdZdS)EvalContextModifiera Modifies the eval context. For each option that should be modified, a :class:`Keyword` has to be added to the :attr:`options` list. Example to change the `autoescape` setting:: EvalContextModifier(options=[Keyword('autoescape', Const(True))]) optionsN)r)rrrrrrrrrrsrc@seZdZdZdZdS)ScopedEvalContextModifierzModifies the eval context and reverts it later. Works exactly like :class:`EvalContextModifier` but will only modify the :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`. r{N)r{)rrrrrrrrrrsrcOs tddS)Nzcan't create custom node types)rH)rrrrr _failing_newsr)srtypesr collectionsrZ jinja2.utilsrZjinja2._compatrrrr FunctionType MethodTypeZ_context_function_typesmultruedivfloordivpowmodaddsubrnot_posnegrrrrgerlerrrr+rrvr2rCrDrxryrzr|r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrisortedr(rrrrrrrrrrrrrrrrrrrrrrrrrr staticmethodr,rrrrs       )        0   &