flask-include、set、with

flask-include、set、with


  • include: 跟django的include类似,将一个html的代码块直接嵌入另一个html文件中
    • {%   include    'html    path'    %}
  • set: 在html中缓存一个变量, 如果set缓存的变量没有被with包裹,那么这个变量可以在这个html的全局使用
    • {%   set    name='ivy'   %}
  • with: 定义一个代码块,该代码块里面定义的变量只能在这个块里面使用
    • with  定义变量:
      • {%   with   name='ivy'  %}
        • content....
      • {%  endwith   %}
    • with  不缓存变量:
      • {%  with   %}
        • content...
      • {%   endwith  %}

猜你喜欢

转载自www.cnblogs.com/ivy-blogs/p/11536496.html