Django DTL模板语法中的判断

  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body ,body>p{
            background: pink;
            text-align: center;
            line-height: 100px;
        }
    </style>

</head>
<body>
{#    {% if age < 18 %}#}
{#        <p>您是未成年人,不能进入网吧</p>#}
{#    {% elif age == 18 %}#}
{#        <p>您是满了18岁,可以进入网吧</p>#}
{#    {% else  %}#}
{#        <p>您已经是成年人了,要承担起家庭的责任了,也不能进入网吧</p>#}
{#    {% endif %}#}
    {% if '蒙多' in heros %}
        <p>砍</p>
    {% else  %}
        <p>蒙多想去哪就去哪</p>
    {% endif %}
</body>
</html>

  

猜你喜欢

转载自www.cnblogs.com/randomlee/p/10291485.html