Debian Codegraph @

docs/intro.rst

raw
1 Introduction
2 ============
3
4 Jinja is a fast, expressive, extensible templating engine. Special
5 placeholders in the template allow writing code similar to Python
6 syntax. Then the template is passed data to render the final document.
7
8 It includes:
9
10 - Template inheritance and inclusion.
11 - Define and import macros within templates.
12 - HTML templates can use autoescaping to prevent XSS from untrusted
13 user input.
14 - A sandboxed environment can safely render untrusted templates.
15 - Async support for generating templates that automatically handle
16 sync and async functions without extra syntax.
17 - I18N support with Babel.
18 - Templates are compiled to optimized Python code just-in-time and
19 cached, or can be compiled ahead-of-time.
20 - Exceptions point to the correct line in templates to make debugging
21 easier.
22 - Extensible filters, tests, functions, and even syntax.
23
24 Jinja's philosophy is that while application logic belongs in Python if
25 possible, it shouldn't make the template designer's job difficult by
26 restricting functionality too much.
27
28
29 Installation
30 ------------
31
32 We recommend using the latest version of Python. Jinja supports Python
33 3.7 and newer. We also recommend using a `virtual environment`_ in order
34 to isolate your project dependencies from other projects and the system.
35
36 .. _virtual environment: https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments
37
38 Install the most recent Jinja version using pip:
39
40 .. code-block:: text
41
42 $ pip install Jinja2
43
44
45 Dependencies
46 ~~~~~~~~~~~~
47
48 These will be installed automatically when installing Jinja.
49
50 - `MarkupSafe`_ escapes untrusted input when rendering templates to
51 avoid injection attacks.
52
53 .. _MarkupSafe: https://markupsafe.palletsprojects.com/
54
55
56 Optional Dependencies
57 ~~~~~~~~~~~~~~~~~~~~~
58
59 These distributions will not be installed automatically.
60
61 - `Babel`_ provides translation support in templates.
62
63 .. _Babel: https://babel.pocoo.org/