Jinja2: 判断变量是否为空、存在等

📝

内容提要

在 Jinja2 模板中,我们经常需要判断一个变量是否存在,里面的值是否为空等等。 检查变量是否存在,或者是否被定义 {% if variable is defined %} variable is defined {% else %} variable is not defined {% endif %} 检查数据的长度是否为空...

🏷️

标签

➡️

继续阅读