Jinja2

Jinja2是为python提供的一个功能齐全的模板引擎。Jinja2提供了对unicode的全支持,以及一个可选集成的沙盒运行环境。它使用BSD协议。

Jinja
原作者Armin Ronacher
源代码库
编程语言Python
类型模板引擎
许可协议BSD许可证
网站palletsprojects.com/p/jinja/ 

主要特性:

  • 沙盒执行模式
  • 针对跨站脚本攻击的自动HTML转义系统
  • 模板继承
  • 即时编译(just-in-time compilation)
  • 可选的静态编译 (ahead-of-time compilation)
  • 内置调试系统
  • 语言风格可配置
  • 设计助手

简单的例子

<!DOCTYPE html>
<html>
  <head>
    <title>{{ variable|escape }}</title>
  </head>
  <body>
  {%- for item in item_list %}
    {{ item }}{% if not loop.last %},{% endif %}
  {%- endfor %}
  </body>
</html>

他们在使用Jinja2:

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.