Jinja2 Documentation Release 2.10## Jinja Jinja2 Documentation Release 2.10 November 08, 2017 Powered by TCPDF (www.tcpdf.org) ## Contents I Jinja2 Documentation 1 1 Introduction 3 2 API 7 3 Sandbox 39 4 Native Python Types Questions 121 11 Jinja Changelog 125 Part I JINJA2 DOCUMENTATION # Introduction This is the documentation for the Jinja2 general purpose templating language. Jinja2 is a library for Python that is designed Prerequisites Jinja2 works with Python 2.6.x, 2.7.x and $ \geq $ 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.70 码力 | 148 页 | 475.08 KB | 2 年前3
Flask 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 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 | 2 年前3
Flask 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 /__init__.py /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 | 2 年前3
Django 5.1 Documentationto use Django's CSRF protection - Using CSRF protection with AJAX - Using CSRF protection in Jinja2 templates - Using the decorator method - Handling rejected requests - Using CSRF protection with template system, creatively called the Django template language (DTL), and for the popular alternative Jinja2 [https://jinja.palletsprojects.com/]. Backends for other template languages may be available from ('django' engine) - /home/html/default/story_detail.html ('django' engine) - /home/html/jinja2/story_detail.html ('jinja2' engine) If you call select_template(['story_253_detail.html'0 码力 | 3513 页 | 3.17 MB | 1 年前3
Flask入门教程一章要学习使用的模板渲染引擎——Jinja2 来完成。 按照默认的设置,Flask 会从程序实例所在模块同级目录的 templates 文件夹中寻找模板,我们的程序目前存储在项目根目录的 app.py 文件里,所以我们要在项目根目录创建这个文件夹: $ mkdir templates ## 模板基本语法 在社交网站上,每个人都有一个主页,借助 Jinja2 就可以写出一个通用的模板:({ {{% else}}
自我介绍为空
{{%endif}} <# 大部分 Jinja 语句都需要声明关闭 #} Jinja2 的语法和 Python 大致相同,你在后面会陆续接触到一些常见的用法。在模板里,你需要添加特定的定界符将 Jinja2 语句和变量标记出来,下面是三种常用的定界符: • {…} 用来标记变量。 {% ... %} 用来标记语句,比如 if 语句,for 是列表,但能够在模板里使用的不只这两种 Python 数据结构,你也可以传入元组、字典、函数等。 render_template() 函数在调用时会识别并执行 index.html 里所有的 Jinja2 语句,返回渲染好的模板内容。在返回的页面中,变量会被替换为实际的值(包括定界符),语句(及定界符)则会在执行后被移除(注释也会一并移除)。 现在访问 http://localhost:5000/0 码力 | 127 页 | 7.62 MB | 1 年前3
Django 5.1.2 Documentationto use Django's CSRF protection - Using CSRF protection with AJAX - Using CSRF protection in Jinja2 templates - Using the decorator method - Handling rejected requests - Using CSRF protection with template system, creatively called the Django template language (DTL), and for the popular alternative Jinja2 [https://jinja.palletsprojects.com/]. Backends for other template languages may be available from ('django' engine) - /home/html/default/story_detail.html ('django' engine) - /home/html/jinja2/story_detail.html ('jinja2' engine) If you call select_template(['story_253_detail.html'0 码力 | 3519 页 | 3.17 MB | 1 年前3
Django 4.1.x Documentationto use Django's CSRF protection - Using CSRF protection with AJAX - Using CSRF protection in Jinja2 templates - Using the decorator method - Handling rejected requests - Using CSRF protection with ('django' engine) - /home/html/default/story_detail.html ('django' engine) - /home/html/jinja2/story_detail.html ('jinja2' engine) If you call select_template(['story_253_detail.html' look for: - /home/html/example.com/story_253_detail.html ('django' engine) - /home/html/jinja2/story_253_detail.html ('jinja2' engine) - /home/html/default/story_253_detail.html ('django'0 码力 | 3240 页 | 3.13 MB | 2 年前3
Django 4.0.x Documentation('django' engine) - /home/html/default/story_detail.html ('django' engine) - /home/html/jinja2/story_detail.html ('jinja2' engine) If you call select_template(['story_253_detail.html' look for: - /home/html/example.com/story_253_detail.html ('django' engine) - /home/html/jinja2/story_253_detail.html ('jinja2' engine) - /home/html/default/story_253_detail.html ('django' ('django' engine) - /home/html/default/story_detail.html ('django' engine) - /home/html/jinja2/story_detail.html ('jinja2' engine) When Django finds a template that exists, it stops looking0 码力 | 3184 页 | 3.14 MB | 2 年前3
Django 2.0.x Documentationfrom previous page) }, { 'BACKEND': 'django.template.backends.jinja2.Jinja2', 'DIRS': [ '/home/html/jinja2', ], }, ] If you call get_template('story_detail.html'), here are the files Django will look for ('django' engine) • /home/html/default/story_detail.html ('django' engine) • /home/html/jinja2/story_detail.html ('jinja2' engine) If you call select_template(['story_253_detail.html', 'story_detail.html']) /home/html/jinja2/story_253_detail.html ('jinja2' engine) • /home/html/example.com/story_detail.html ('django' engine) • /home/html/default/story_detail.html ('django' engine) • /home/html/jinja2/story_detail0 码力 | 1880 页 | 6.41 MB | 2 年前3
Django 1.11.x Documentation'/home/html/default', ], }, { 'BACKEND': 'django.template.backends.jinja2.Jinja2', 'DIRS': [ '/home/html/jinja2', ], }, ] If you call get_template('story_detail.html'), here are the files Django will look for Templates 271 Django Documentation, Release 1.11.30.dev20200305075726 • /home/html/jinja2/story_detail.html ('jinja2' engine) If you call select_template(['story_253_detail.html', 'story_detail.html']) /home/html/jinja2/story_253_detail.html ('jinja2' engine) • /home/html/example.com/story_detail.html ('django' engine) • /home/html/default/story_detail.html ('django' engine) • /home/html/jinja2/story_detail0 码力 | 1878 页 | 6.40 MB | 2 年前3
共 277 条
- 1
- 2
- 3
- 4
- 5
- 6
- 28













