zoukankan      html  css  js  c++  java
  • 模板宏的使用

    一.模板宏的使用

      macro_demo.py

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    #author tom
    
    
    from flask import Flask,render_template
    
    
    app = Flask(__name__)
    
    @app.route("/")
    def func():
        return render_template("macro.html")
    
    
    if __name__ == '__main__':
        app.run(debug=True)

      macro.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>模板宏的使用</title>
    </head>
    <body>
        //不带参数的宏
        {% macro input() %}
            <input type="text" name="" id="" size="30">
        {% endmacro %}
    
        <h1>input</h1>
        {{ input() }}
        <h1>input2</h1>
        {{ input() }}
    
        //带参数的宏
        {% macro input2(type,value,size) %}
            <input type="{{ type }}"  value="{{ value }}" size="{{ size }}">
        {% endmacro %}
    
        <h1>带参数宏</h1>
        {{ input2("text","",50) }}
    </body>
    </html>

      宏定义在外部

        {% macro input5() %}
            <input type="text"   size="20">
        {% endmacro %}
  • 相关阅读:
    IO流
    集合中的工具类Collections和Arrays
    排序 查找
    函数及数组
    变量、静态的和单例模式
    java流程控制
    configure使用
    --sysroot
    LD_PRELOAD
    Linux下内存检测工具:asan :编译-连接-运行选项
  • 原文地址:https://www.cnblogs.com/tjp40922/p/11925096.html
Copyright © 2011-2022 走看看