Jinja2 Documentation Release 2.10
Jinja2 Documentation Release 2.10 November 08, 2017 Contents I Jinja2 Documentation 1 1 Introduction 3 2 API 7 3 Sandbox 39 4 Native Python Types 45 5 Template Designer Documentation 47 6 Extensions Jinja Changelog 125 i ii Part I JINJA2 DOCUMENTATION 1 2 CHAPTER 1 Introduction This is the documentation for the Jinja2 general purpose templating language. Jinja2 is a library for Python that is Prerequisites Jinja2 works with Python 2.6.x, 2.7.x and >= 3.3. If you are using Python 3.2 you can use an older release of Jinja2 (2.6) as support for Python 3.2 was dropped in Jinja2 version 2.7. If0 码力 | 148 页 | 475.08 KB | 1 年前3Flask Documentation (1.1.x)
cross-site scripting (XSS). Unless you deliberately mark insecure HTML as secure, Flask and the underlying Jinja2 template engine have you covered. But there are many more ways to cause security problems. The documentation the HTML escaping on your own to keep the application secure. Because of that Flask configures the Jinja2 [http://jinja.pocoo.org/] template engine for you automatically. To render a template you can use /templates /hello.html For templates you can use the full power of Jinja2 templates. Head over to the official Jinja2 Template Documentation [http://jinja.pocoo.org/docs/templates/] for more information0 码力 | 428 页 | 895.98 KB | 1 年前3Flask Documentation (1.1.x)
scripting (XSS). Unless you delib- erately mark insecure HTML as secure, Flask and the underlying Jinja2 template engine have you covered. But there are many more ways to cause security problems. The documentation the HTML escaping on your own to keep the application secure. Because of that Flask configures the Jinja2 template engine for you automatically. To render a template you can use the render_template() method /__init__.py /templates /hello.html For templates you can use the full power of Jinja2 templates. Head over to the official Jinja2 Template Documentation for more information. Here is an example template:0 码力 | 291 页 | 1.25 MB | 1 年前3Flask入门教程
要学习使用的模板渲 染引擎——Jinja2 来完成。 按照默认的设置,Flask 会从程序实例所在模块同级目录的 templates 文件夹中寻 找模板,我们的程序目前存储在项目根目录的 app.py 文件里,所以我们要在项目 根目录创建这个文件夹: $ mkdir templates 模板基本语法 在社交网站上,每个人都有一个主页,借助 Jinja2 就可以写出一个通用的模板:{{ else %}
自我介绍为空。
{% endif %} {# 大部分 Jinja 语句都需要声明关闭 #} Jinja2 的语法和 Python 大致相同,你在后面会陆续接触到一些常见的用法。在模 板里,你需要添加特定的定界符将 Jinja2 语句和变量标记出来,下面是三种常用的 定界符: {{ ... }} 用来标记变量。 {% ... %} 用来标记语句,比如 href="http://helloflask.com/tutori al">HelloFlask