你可以編寫擴展來向 Jinja2 中添加自定義標簽。這是一個不平凡的任務,而且通常不需 要,因為默認的標簽和表達式涵蓋了所有常用情況。如 i18n 擴展是一個擴展有用的好例 子,而另一個會是碎片緩存。
當你編寫擴展時,你需要記住你在與 Jinja2 模板編譯器一同工作,而它并不驗證你傳遞 到它的節點樹。如果 AST 是畸形的,你會得到各種各樣的編譯器或運行時錯誤,這調試起 來極其可怕。始終確保你在使用創建正確的節點。下面的 API 文檔展示了有什么節點和如 何使用它們。
### 示例擴展[](http://docs.jinkan.org/docs/jinja2/extensions.html#id9 "Permalink to this headline")
下面的例子用?[Werkzeug](http://werkzeug.pocoo.org/)?的緩存 contrib 模塊為 Jinja2 實現了一個?cache?標簽:
~~~
from jinja2 import nodes
from jinja2.ext import Extension
class FragmentCacheExtension(Extension):
# a set of names that trigger the extension.
tags = set(['cache'])
def __init__(self, environment):
super(FragmentCacheExtension, self).__init__(environment)
# add the defaults to the environment
environment.extend(
fragment_cache_prefix='',
fragment_cache=None
)
def parse(self, parser):
# the first token is the token that started the tag. In our case
# we only listen to ``'cache'`` so this will be a name token with
# `cache` as value. We get the line number so that we can give
# that line number to the nodes we create by hand.
lineno = parser.stream.next().lineno
# now we parse a single expression that is used as cache key.
args = [parser.parse_expression()]
# if there is a comma, the user provided a timeout. If not use
# None as second parameter.
if parser.stream.skip_if('comma'):
args.append(parser.parse_expression())
else:
args.append(nodes.Const(None))
# now we parse the body of the cache block up to `endcache` and
# drop the needle (which would always be `endcache` in that case)
body = parser.parse_statements(['name:endcache'], drop_needle=True)
# now return a `CallBlock` node that calls our _cache_support
# helper method on this extension.
return nodes.CallBlock(self.call_method('_cache_support', args),
[], [], body).set_lineno(lineno)
def _cache_support(self, name, timeout, caller):
"""Helper callback."""
key = self.environment.fragment_cache_prefix + name
# try to load the block from the cache
# if there is no fragment in the cache, render it and store
# it in the cache.
rv = self.environment.fragment_cache.get(key)
if rv is not None:
return rv
rv = caller()
self.environment.fragment_cache.add(key, rv, timeout)
return rv
~~~
而這是你在環境中使用它的方式:
~~~
from jinja2 import Environment
from werkzeug.contrib.cache import SimpleCache
env = Environment(extensions=[FragmentCacheExtension])
env.fragment_cache = SimpleCache()
~~~
之后,在模板中可以標記塊為可緩存的。下面的例子緩存一個邊欄 300 秒:
~~~
{% cache 'sidebar', 300 %}
<div class="sidebar">
...
</div>
{% endcache %}
~~~
### 擴展 API[](http://docs.jinkan.org/docs/jinja2/extensions.html#api "Permalink to this headline")
擴展總是繼承?[jinja2.ext.Extension](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension "jinja2.ext.Extension")?類:
*class?*jinja2.ext.Extension(*environment*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension "Permalink to this definition")
Extensions can be used to add extra functionality to the Jinja template system at the parser level. Custom extensions are bound to an environment but may not store environment specific data on?self. The reason for this is that an extension can be bound to another environment (for overlays) by creating a copy and reassigning theenvironment?attribute.
As extensions are created by the environment they cannot accept any arguments for configuration. One may want to work around that by using a factory function, but that is not possible as extensions are identified by their import name. The correct way to configure the extension is storing the configuration values on the environment. Because this way the environment ends up acting as central configuration storage the attributes may clash which is why extensions have to ensure that the names they choose for configuration are not too generic.?prefix?for example is a terrible name,fragment_cache_prefix?on the other hand is a good name as includes the name of the extension (fragment cache).
identifier[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.identifier "Permalink to this definition")
擴展的標識符。這始終是擴展類的真實導入名,不能被修改。
tags[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.tags "Permalink to this definition")
如果擴展實現自定義標簽,這是擴展監聽的標簽名的集合。
attr(*name*,?*lineno=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.attr "Permalink to this definition")
Return an attribute node for the current extension. This is useful to pass constants on extensions to generated template code.
~~~
self.attr('_my_attribute', lineno=lineno)
~~~
call_method(*name*,?*args=None*,?*kwargs=None*,?*dyn_args=None*,*dyn_kwargs=None*,?*lineno=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.call_method "Permalink to this definition")
Call a method of the extension. This is a shortcut for?[attr()](http://docs.jinkan.org/docs/jinja2/templates.html#attr "attr")?+?[jinja2.nodes.Call](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Call "jinja2.nodes.Call").
filter_stream(*stream*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.filter_stream "Permalink to this definition")
It’s passed a?[TokenStream](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream "jinja2.lexer.TokenStream")?that can be used to filter tokens returned. This method has to return an iterable of?[Token](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.Token "jinja2.lexer.Token")s, but it doesn’t have to return a?[TokenStream](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream "jinja2.lexer.TokenStream").
In the?ext?folder of the Jinja2 source distribution there is a file calledinlinegettext.py?which implements a filter that utilizes this method.
parse(*parser*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.parse "Permalink to this definition")
If any of the?[tags](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.tags "jinja2.ext.Extension.tags")?matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.
preprocess(*source*,?*name*,?*filename=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.preprocess "Permalink to this definition")
This method is called before the actual lexing and can be used to preprocess the source. The?filename?is optional. The return value must be the preprocessed source.
### 解析器 API[](http://docs.jinkan.org/docs/jinja2/extensions.html#id10 "Permalink to this headline")
傳遞到?[Extension.parse()](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.parse "jinja2.ext.Extension.parse")?的解析器提供解析不同類型表達式的方式。下 面的方法可能會在擴展中使用:
*class?*jinja2.parser.Parser(*environment*,?*source*,?*name=None*,?*filename=None*,*state=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser "Permalink to this definition")
This is the central parsing class Jinja2 uses. It’s passed to extensions and can be used to parse expressions or statements.
filename[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Parser.filename "Permalink to this definition")
解析器處理的模板文件名。這?**不是**?模板的加載名。加載名見?[name](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Parser.name "jinja2.ext.Parser.name")?。對于不是從文件系統中加載的模板,這個值為?None?。
name[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Parser.name "Permalink to this definition")
模板的加載名。
stream[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Parser.stream "Permalink to this definition")
當前的?[TokenStream](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream "jinja2.lexer.TokenStream")?。
fail(*msg*,?*lineno=None*,?*exc=*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.fail "Permalink to this definition")
Convenience method that raises?exc?with the message, passed line number or last line number as well as the current name and filename.
free_identifier(*lineno=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.free_identifier "Permalink to this definition")
Return a new free identifier as?[InternalName](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.InternalName "jinja2.nodes.InternalName").
parse_assign_target(*with_tuple=True*,?*name_only=False*,*extra_end_rules=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.parse_assign_target "Permalink to this definition")
Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting?with_tuple?to?False. If only assignments to names are wanted?name_only?can be set to?True. Theextra_end_rules?parameter is forwarded to the tuple parsing function.
parse_expression(*with_condexpr=True*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.parse_expression "Permalink to this definition")
Parse an expression. Per default all expressions are parsed, if the optionalwith_condexpr?parameter is set to?False?conditional expressions are not parsed.
parse_statements(*end_tokens*,?*drop_needle=False*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.parse_statements "Permalink to this definition")
Parse multiple statements into a list until one of the end tokens is reached. This is used to parse the body of statements as it also parses template data if appropriate. The parser checks first if the current token is a colon and skips it if there is one. Then it checks for the block end and parses until if one of the?end_tokens?is reached. Per default the active token in the stream at the end of the call is the matched end token. If this is not wanted?drop_needle?can be set to?True?and the end token is removed.
parse_tuple(*simplified=False*,?*with_condexpr=True*,?*extra_end_rules=None*,*explicit_parentheses=False*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.parse_tuple "Permalink to this definition")
Works like?parse_expression?but if multiple expressions are delimited by a comma a?[Tuple](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Tuple "jinja2.nodes.Tuple")?node is created. This method could also return a regular expression instead of a tuple if no commas where found.
The default parsing mode is a full tuple. If?simplified?is?True?only names and literals are parsed. The?no_condexpr?parameter is forwarded toparse_expression().
Because tuples do not require delimiters and may end in a bogus comma an extra hint is needed that marks the end of a tuple. For example for loops support tuples between?for?and?in. In that case the?extra_end_rules?is set to?['name:in'].
explicit_parentheses?is true if the parsing was triggered by an expression in parentheses. This is used to figure out if an empty tuple is a valid expression or not.
*class?*jinja2.lexer.TokenStream(*generator*,?*name*,?*filename*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream "Permalink to this definition")
A token stream is an iterable that yields?Tokens. The parser however does not iterate over it but calls?next()?to go one token ahead. The current active token is stored as[current](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.TokenStream.current "jinja2.ext.TokenStream.current").
current[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.TokenStream.current "Permalink to this definition")
當前的?[Token](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.Token "jinja2.lexer.Token")?。
eos[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.eos "Permalink to this definition")
Are we at the end of the stream?
expect(*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.expect "Permalink to this definition")
Expect a given token type and return it. This accepts the same argument as[jinja2.lexer.Token.test()](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.Token.test "jinja2.lexer.Token.test").
look()[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.look "Permalink to this definition")
Look at the next token.
next()[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.next "Permalink to this definition")
Go one token ahead and return the old one
next_if(*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.next_if "Permalink to this definition")
Perform the token test and return the token if it matched. Otherwise the return value is?None.
push(*token*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.push "Permalink to this definition")
Push a token back to the stream.
skip(*n=1*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.skip "Permalink to this definition")
Got n tokens ahead.
skip_if(*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.TokenStream.skip_if "Permalink to this definition")
Like?next_if()?but only returns?True?or?False.
*class?*jinja2.lexer.Token[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.Token "Permalink to this definition")
Token class.
lineno[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Token.lineno "Permalink to this definition")
token 的行號。
type[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Token.type "Permalink to this definition")
token 的類型。這個值是被禁錮的,所以你可以用?is?運算符同任意字符 串比較。
value[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Token.value "Permalink to this definition")
token 的值。
test(*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.Token.test "Permalink to this definition")
Test a token against a token expression. This can either be a token type or'token_type:token_value'. This can only test against string values and types.
test_any(**iterable*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.lexer.Token.test_any "Permalink to this definition")
Test against multiple token expressions.
同樣,在詞法分析模塊中也有一個實用函數可以計算字符串中的換行符數目:
~~~
.. autofunction:: jinja2.lexer.count_newlines
~~~
### AST[](http://docs.jinkan.org/docs/jinja2/extensions.html#ast "Permalink to this headline")
AST(抽象語法樹: Abstract Syntax Tree)用于表示解析后的模板。它有編譯器之后 轉換到可執行的 Python 代碼對象的節點構建。提供自定義語句的擴展可以返回執行自 定義 Python 代碼的節點。
下面的清單展示了所有當前可用的節點。 AST 在 Jinja2 的各個版本中有差異,但會向 后兼容。
更多信息請見?[jinja2.Environment.parse()](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Environment.parse "jinja2.Environment.parse")?。
*class?*jinja2.nodes.Node[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node "Permalink to this definition")
Baseclass for all Jinja2 nodes. There are a number of nodes available of different types. There are four major types:
* [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt"): statements
* [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr"): expressions
* [Helper](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Helper "jinja2.nodes.Helper"): helper nodes
* [Template](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Template "jinja2.nodes.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.
find(*node_type*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.find "Permalink to this definition")
Find the first node of a given type. If no such node exists the return value isNone.
find_all(*node_type*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.find_all "Permalink to this definition")
Find all the nodes of a given type. If the type is a tuple, the check is performed for any of the tuple items.
iter_child_nodes(*exclude=None*,?*only=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.iter_child_nodes "Permalink to this definition")
Iterates 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.
iter_fields(*exclude=None*,?*only=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.iter_fields "Permalink to this definition")
This 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.
set_ctx(*ctx*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.set_ctx "Permalink to this definition")
Reset 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.
set_environment(*environment*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.set_environment "Permalink to this definition")
Set the environment for all nodes.
set_lineno(*lineno*,?*override=False*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node.set_lineno "Permalink to this definition")
Set the line numbers of the node and children.
*class?*jinja2.nodes.Expr[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "Permalink to this definition")
Baseclass for all expressions.
Node type: [Node](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node "jinja2.nodes.Node")
as_const(*eval_ctx=None*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr.as_const "Permalink to this definition")
Return the value of the expression as constant or raise?[Impossible](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Impossible "jinja2.nodes.Impossible")?if this was not possible.
An?[EvalContext](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.nodes.EvalContext "jinja2.nodes.EvalContext")?can be provided, if none is given a default context is created which requires the nodes to have an attached environment.
Changed in version 2.4:?the?eval_ctx?parameter was added.
can_assign()[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr.can_assign "Permalink to this definition")
Check if it’s possible to assign something to this node.
*class?*jinja2.nodes.BinExpr(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "Permalink to this definition")
Baseclass for all binary expressions.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Add(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Add "Permalink to this definition")
Add the left to the right node.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.And(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.And "Permalink to this definition")
Short circuited AND.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Div(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Div "Permalink to this definition")
Divides the left by the right node.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.FloorDiv(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.FloorDiv "Permalink to this definition")
Divides the left by the right node and truncates conver the result into an integer by truncating.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Mod(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Mod "Permalink to this definition")
Left modulo right.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Mul(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Mul "Permalink to this definition")
Multiplies the left with the right node.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Or(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Or "Permalink to this definition")
Short circuited OR.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Pow(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Pow "Permalink to this definition")
Left to the power of right.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Sub(*left*,?*right*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Sub "Permalink to this definition")
Substract the right from the left node.
Node type: [BinExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.BinExpr "jinja2.nodes.BinExpr")
*class?*jinja2.nodes.Call(*node*,?*args*,?*kwargs*,?*dyn_args*,?*dyn_kwargs*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Call "Permalink to this definition")
Calls an expression.?args?is a list of arguments,?kwargs?a list of keyword arguments (list of?[Keyword](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Keyword "jinja2.nodes.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.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Compare(*expr*,?*ops*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Compare "Permalink to this definition")
Compares an expression with some other expressions.?ops?must be a list of?[Operand](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Operand "jinja2.nodes.Operand")s.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Concat(*nodes*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Concat "Permalink to this definition")
Concatenates the list of expressions provided after converting them to unicode.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.CondExpr(*test*,?*expr1*,?*expr2*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.CondExpr "Permalink to this definition")
A conditional expression (inline if expression). ({{?foo?if?bar?else?baz?}})
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.ContextReference[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.ContextReference "Permalink to this definition")
Returns the current template context. It can be used like a?[Name](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Name "jinja2.nodes.Name")?node, with a?'load'ctx and will return the current?[Context](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.runtime.Context "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'))
~~~
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.EnvironmentAttribute(*name*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.EnvironmentAttribute "Permalink to this definition")
Loads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.ExtensionAttribute(*identifier*,?*name*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.ExtensionAttribute "Permalink to this definition")
Returns the attribute of an extension bound to the environment. The identifier is the identifier of the?Extension.
This node is usually constructed by calling the?[attr()](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.ext.Extension.attr "jinja2.ext.Extension.attr")?method on an extension.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Filter(*node*,?*name*,?*args*,?*kwargs*,?*dyn_args*,?*dyn_kwargs*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Filter "Permalink to this definition")
This node applies a filter on an expression.?name?is the name of the filter, the rest of the fields are the same as for?[Call](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Call "jinja2.nodes.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.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Getattr(*node*,?*attr*,?*ctx*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Getattr "Permalink to this definition")
Get an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Getitem(*node*,?*arg*,?*ctx*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Getitem "Permalink to this definition")
Get an attribute or item from an expression and prefer the item.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.ImportedName(*importname*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.ImportedName "Permalink to this definition")
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.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.InternalName(*name*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.InternalName "Permalink to this definition")
An internal name in the compiler. You cannot create these nodes yourself but the parser provides a?[free_identifier()](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.parser.Parser.free_identifier "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.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Literal[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Literal "Permalink to this definition")
Baseclass for literals.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Const(*value*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Const "Permalink to this definition")
All 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).
Node type: [Literal](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Literal "jinja2.nodes.Literal")
*class?*jinja2.nodes.Dict(*items*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Dict "Permalink to this definition")
Any dict literal such as?{1:?2,?3:?4}. The items must be a list of?[Pair](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Pair "jinja2.nodes.Pair")?nodes.
Node type: [Literal](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Literal "jinja2.nodes.Literal")
*class?*jinja2.nodes.List(*items*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.List "Permalink to this definition")
Any list literal such as?[1,?2,?3]
Node type: [Literal](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Literal "jinja2.nodes.Literal")
*class?*jinja2.nodes.TemplateData(*data*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.TemplateData "Permalink to this definition")
A constant template string.
Node type: [Literal](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Literal "jinja2.nodes.Literal")
*class?*jinja2.nodes.Tuple(*items*,?*ctx*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Tuple "Permalink to this definition")
For loop unpacking and some other things like multiple arguments for subscripts. Like for?[Name](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Name "jinja2.nodes.Name")?ctx?specifies if the tuple is used for loading the names or storing.
Node type: [Literal](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Literal "jinja2.nodes.Literal")
*class?*jinja2.nodes.MarkSafe(*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.MarkSafe "Permalink to this definition")
Mark the wrapped expression as safe (wrap it as?Markup).
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.MarkSafeIfAutoescape(*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.MarkSafeIfAutoescape "Permalink to this definition")
Mark the wrapped expression as safe (wrap it as?Markup) but only if autoescaping is active.
New in version 2.5.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Name(*name*,?*ctx*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Name "Permalink to this definition")
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.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Slice(*start*,?*stop*,?*step*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Slice "Permalink to this definition")
Represents a slice object. This must only be used as argument for?Subscript.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Test(*node*,?*name*,?*args*,?*kwargs*,?*dyn_args*,?*dyn_kwargs*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Test "Permalink to this definition")
Applies a test on an expression.?name?is the name of the test, the rest of the fields are the same as for?[Call](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Call "jinja2.nodes.Call").
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.UnaryExpr(*node*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.UnaryExpr "Permalink to this definition")
Baseclass for all unary expressions.
Node type: [Expr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Expr "jinja2.nodes.Expr")
*class?*jinja2.nodes.Neg(*node*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Neg "Permalink to this definition")
Make the expression negative.
Node type: [UnaryExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.UnaryExpr "jinja2.nodes.UnaryExpr")
*class?*jinja2.nodes.Not(*node*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Not "Permalink to this definition")
Negate the expression.
Node type: [UnaryExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.UnaryExpr "jinja2.nodes.UnaryExpr")
*class?*jinja2.nodes.Pos(*node*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Pos "Permalink to this definition")
Make the expression positive (noop for most expressions)
Node type: [UnaryExpr](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.UnaryExpr "jinja2.nodes.UnaryExpr")
*class?*jinja2.nodes.Helper[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Helper "Permalink to this definition")
Nodes that exist in a specific context only.
Node type: [Node](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node "jinja2.nodes.Node")
*class?*jinja2.nodes.Keyword(*key*,?*value*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Keyword "Permalink to this definition")
A key, value pair for keyword arguments where key is a string.
Node type: [Helper](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Helper "jinja2.nodes.Helper")
*class?*jinja2.nodes.Operand(*op*,?*expr*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Operand "Permalink to this definition")
Holds an operator and an expression. The following operators are available:?%,?**,?*,?+,-,?//,?/,?eq,?gt,?gteq,?in,?lt,?lteq,?ne,?not,?notin
Node type: [Helper](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Helper "jinja2.nodes.Helper")
*class?*jinja2.nodes.Pair(*key*,?*value*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Pair "Permalink to this definition")
A key, value pair for dicts.
Node type: [Helper](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Helper "jinja2.nodes.Helper")
*class?*jinja2.nodes.Stmt[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "Permalink to this definition")
Base node for all statements.
Node type: [Node](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node "jinja2.nodes.Node")
*class?*jinja2.nodes.Assign(*target*,?*node*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Assign "Permalink to this definition")
Assigns an expression to a target.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Block(*name*,?*body*,?*scoped*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Block "Permalink to this definition")
A node that represents a block.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Break[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Break "Permalink to this definition")
Break a loop.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.CallBlock(*call*,?*args*,?*defaults*,?*body*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.CallBlock "Permalink to this definition")
Like a macro without a name but a call instead.?call?is called with the unnamed macro as?caller?argument this node holds.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Continue[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Continue "Permalink to this definition")
Continue a loop.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.EvalContextModifier(*options*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.EvalContextModifier "Permalink to this definition")
Modifies the eval context. For each option that should be modified, a?[Keyword](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Keyword "jinja2.nodes.Keyword")?has to be added to the?options?list.
Example to change the?autoescape?setting:
~~~
EvalContextModifier(options=[Keyword('autoescape', Const(True))])
~~~
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.ScopedEvalContextModifier(*options*,?*body*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.ScopedEvalContextModifier "Permalink to this definition")
Modifies the eval context and reverts it later. Works exactly like?[EvalContextModifier](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.EvalContextModifier "jinja2.nodes.EvalContextModifier")but will only modify the?[EvalContext](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.nodes.EvalContext "jinja2.nodes.EvalContext")?for nodes in the?body.
Node type: [EvalContextModifier](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.EvalContextModifier "jinja2.nodes.EvalContextModifier")
*class?*jinja2.nodes.ExprStmt(*node*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.ExprStmt "Permalink to this definition")
A statement that evaluates an expression and discards the result.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Extends(*template*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Extends "Permalink to this definition")
Represents an extends statement.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.FilterBlock(*body*,?*filter*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.FilterBlock "Permalink to this definition")
Node for filter sections.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.For(*target*,?*iter*,?*body*,?*else_*,?*test*,?*recursive*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.For "Permalink to this definition")
The for loop.?target?is the target for the iteration (usually a?[Name](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Name "jinja2.nodes.Name")?or?[Tuple](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Tuple "jinja2.nodes.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.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.FromImport(*template*,?*names*,?*with_context*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.FromImport "Permalink to this definition")
A 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.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.If(*test*,?*body*,?*else_*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.If "Permalink to this definition")
If?test?is true,?body?is rendered, else?else_.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Import(*template*,?*target*,?*with_context*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Import "Permalink to this definition")
A node that represents the import tag.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Include(*template*,?*with_context*,?*ignore_missing*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Include "Permalink to this definition")
A node that represents the include tag.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Macro(*name*,?*args*,?*defaults*,?*body*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Macro "Permalink to this definition")
A macro definition.?name?is the name of the macro,?args?a list of arguments anddefaults?a list of defaults if there are any.?body?is a list of nodes for the macro body.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Output(*nodes*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Output "Permalink to this definition")
A node that holds multiple expressions which are then printed out. This is used both for the?print?statement and the regular template data.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Scope(*body*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Scope "Permalink to this definition")
An artificial scope.
Node type: [Stmt](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Stmt "jinja2.nodes.Stmt")
*class?*jinja2.nodes.Template(*body*)[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Template "Permalink to this definition")
Node that represents a template. This must be the outermost node that is passed to the compiler.
Node type: [Node](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Node "jinja2.nodes.Node")
*exception?*jinja2.nodes.Impossible[](http://docs.jinkan.org/docs/jinja2/extensions.html#jinja2.nodes.Impossible "Permalink to this definition")
Raised if the node could not perform a requested action.
- 介紹
- 預備知識
- 安裝
- 基本 API 使用
- 實驗性的 Python 3 支持
- API
- 基礎
- Unicode
- 高層 API
- 自動轉義
- 標識符的說明
- 未定義類型
- 上下文
- 加載器
- 字節碼緩存
- 實用工具
- 異常
- 自定義過濾器
- 求值上下文
- 自定義測試
- 全局命名空間
- 低層 API
- 元 API
- 沙箱
- API
- 運算符攔截
- 模板設計者文檔
- 概要
- 變量
- 過濾器
- 測試
- 注釋
- 空白控制
- 轉義
- 行語句
- 模板繼承
- HTML 轉義
- 控制結構清單
- 導入上下文行為
- 表達式
- 內置過濾器清單
- 內置測試清單
- 全局函數清單
- 擴展
- 自動轉義擴展
- 擴展
- 添加擴展
- i18n 擴展
- 表達式語句
- 循環控制
- With 語句
- 自動轉義擴展
- 編寫擴展
- 集成
- Babel 集成
- Pylons
- TextMate
- Vim
- 從其它的模板引擎切換
- Jinja1
- Django
- Mako
- 提示和技巧
- Null-Master 退回
- 交替的行
- 高亮活動菜單項
- 訪問父級循環