zoukankan      html  css  js  c++  java
  • Jinja2 笔记

    注释: {# haha #}

    对象引用 : {{data.name}}  或者 {{data['name]}}

    控制语句放到{%  %}中

            {% if not has_in_gifts and not has_in_wishes %}
                <div class="col-md-1">
                    <a class="btn btn-outline"
                       href="#modal">
                        赠送此书
                    </a>
                </div>
            {% elif has_in_wishes %}
                <div class="col-md-3">
                    <span class="bg-info">已添加至心愿清单</span>
                </div>
            {% else %}
                <div class="col-md-3">
                    <span class="bg-info">已添加至赠送清单</span>
                </div>
            {% endif %}
                 {% for message in messages %}
                    {% if message %}
                        <div class="alert alert-warning" role="alert">{{ message }}</div>
                    {% endif %}
                {% endfor %}

     遍历的对象是一个字典

               {% for key, error in form.errors.items() %}
                    <div class="alert alert-warning" role="alert">{{ error }}</div>
                {% endfor %}

     

     获取闪现消息,with是变量作用域的限定

             {% with messages = get_flashed_messages() %}
                {% for message in messages %}
                    {% if message %}
                        <div class="alert alert-warning" role="alert">{{ message }}</div>
                    {% endif %}
                {% endfor %}
            {% endwith %}
  • 相关阅读:
    SQL Server Management Studio
    uiimage拉伸
    时间空间复杂度
    冒泡选择排序

    插入排序
    快速构建APP
    TTTAtibutedlabel
    Git命令
    适配
  • 原文地址:https://www.cnblogs.com/testzcy/p/11785968.html
Copyright © 2011-2022 走看看