boolean(价值)如果对象是布尔值,则返回 true。
callable(obj,/)返回对象是否可调用(即某种函数)。
请注意,类是可调用的,使用 __call__)方法的类的实例也是可调用的。
defined(价值)如果定义了变量,则返回 true:
{% if variable is defined %}
value of variable: {{ variable }}
{% else %}
variable is not defined
{% endif %}
divisibleby(值, num)检查变量是否可被数字除除
escaped(价值)检查该值是否转义。
even(价值)如果变量是均值,则返回 true。
false(价值)如果对象为 False,则返回 true。
float(价值)如果对象是浮点,则返回 true。
ge(a, b,/)与 >\ b 相同。
- 别名
>=
gt(a, b,/)与 > b 相同。
- 别名
>,greaterthan
in(值, seq)检查值是否位于 seq 中。
更改日志
integer(价值)如果对象是整数,则返回 true。
iterable(价值)检查是否可能对对象进行迭代。
le(a, b,/)与 <= b 相同。
- 别名
<=
lower(价值)如果变量已降低,则返回 true。
lt(a, b,/)与 < b 相同。
- 别名
<,lessthan
mapping(价值)如果对象是映射(命令等),则返回 true。
ne(a, b,/)与 != b 相同。
- 别名
!=
none(价值)如果变量为 none,则返回 true。
number(价值)如果变量是数字,则返回 true。
odd(价值)如果变量为奇数,则返回 true。
sameas(值,其他)检查对象是否指向与另一个对象相同的内存地址:
{% if foo.attribute is sameas false %}
the foo attribute really is the `False` singleton
{% endif %}
sequence(价值)如果变量是序列,则返回 true。序列是可重复的变量。
string(价值)如果对象是字符串,则返回 true。
true(价值)如果对象为 True,则返回 true。
undefined(价值)喜欢定义()但相反。
upper(价值)如果变量已上加,则返回 true。