Django Book 翻译
菜单>:
TOC
返回
原文:
A ``for`` tag acts as a simple loop construct, letting you loop over each item in a sequence. An ``if`` tag, as you may expect, acts as a logical if statement. In this particular case, the tag checks whether the value of the ``ordered_warranty`` variable evaluates to ``True`` . If it does, the template system will display everything between the ``{% if ordered_warranty %}`` and ``{% endif %}`` . If not, the template system wont display it. The template system also supports ``{% else %}`` and other various logic statements.
翻译:
``for`` 标签用于构建简单的循环,允许你遍历循环中的每一项。 ``if`` 标签,正如你所料,是用来执行逻辑判断的。在这个例子中标签检测 ``ordered_warranty`` 变量值是否为 ``True`` 。 如果是,模板系统将显示 ``{% if ordered_warranty %}`` 与 ``{% endif %}`` 之间的所有内容。 如果不是模板系统不会显示它。它当然也支持 ``{% else %}`` 以及其他多种逻辑判断方式。
备注:
译者: