内置测试清单

最后更新于:2022-04-01 04:04:17

callable(*object*)[](http://docs.jinkan.org/docs/jinja2/templates.html#callable "Permalink to this definition") Return whether the object is callable (i.e., some kind of function). Note that classes are callable, as are instances with a __call__() method. defined(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#defined "Permalink to this definition") Return true if the variable is defined: ~~~ {% if variable is defined %} value of variable: {{ variable }} {% else %} variable is not defined {% endif %} ~~~ See the [default()](http://docs.jinkan.org/docs/jinja2/templates.html#default "default") filter for a simple way to set undefined variables. divisibleby(*value*, *num*)[](http://docs.jinkan.org/docs/jinja2/templates.html#divisibleby "Permalink to this definition") Check if a variable is divisible by a number. escaped(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#escaped "Permalink to this definition") Check if the value is escaped. even(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#even "Permalink to this definition") Return true if the variable is even. iterable(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#iterable "Permalink to this definition") Check if it’s possible to iterate over an object. lower(*value*) Return true if the variable is lowercased. mapping(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#mapping "Permalink to this definition") Return true if the object is a mapping (dict etc.). New in version 2.6. none(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#none "Permalink to this definition") Return true if the variable is none. number(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#number "Permalink to this definition") Return true if the variable is a number. odd(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#odd "Permalink to this definition") Return true if the variable is odd. sameas(*value*, *other*)[](http://docs.jinkan.org/docs/jinja2/templates.html#sameas "Permalink to this definition") Check if an object points to the same memory address than another object: ~~~ {% if foo.attribute is sameas false %} the foo attribute really is the `False` singleton {% endif %} ~~~ sequence(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#sequence "Permalink to this definition") Return true if the variable is a sequence. Sequences are variables that are iterable. string(*value*) Return true if the object is a string. undefined(*value*)[](http://docs.jinkan.org/docs/jinja2/templates.html#undefined "Permalink to this definition") Like [defined()](http://docs.jinkan.org/docs/jinja2/templates.html#defined "defined") but the other way round. upper(*value*) Return true if the variable is uppercased.
';