Browse code

tweaked doc markup

Fabien Potencier authored on 25/04/2019 10:11:58
Showing 80 changed files
... ...
@@ -40,7 +40,7 @@ generate).
40 40
 
41 41
 You can use a ``lipsum`` *tag*:
42 42
 
43
-.. code-block:: jinja
43
+.. code-block:: twig
44 44
 
45 45
     {% lipsum 40 %}
46 46
 
... ...
@@ -51,7 +51,7 @@ three main reasons:
51 51
 * The tag outputs something;
52 52
 * The tag is not flexible as you cannot use it in an expression:
53 53
 
54
-  .. code-block:: jinja
54
+  .. code-block:: twig
55 55
 
56 56
       {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }}
57 57
 
... ...
@@ -60,7 +60,7 @@ the most complex extension point of Twig.
60 60
 
61 61
 Now, let's use a ``lipsum`` *filter*:
62 62
 
63
-.. code-block:: jinja
63
+.. code-block:: twig
64 64
 
65 65
     {{ 40|lipsum }}
66 66
 
... ...
@@ -71,14 +71,14 @@ transform).
71 71
 
72 72
 Next, let's use a ``lipsum`` *function*:
73 73
 
74
-.. code-block:: jinja
74
+.. code-block:: twig
75 75
 
76 76
     {{ lipsum(40) }}
77 77
 
78 78
 Here we go. For this specific example, the creation of a function is the
79 79
 extension point to use. And you can use it anywhere an expression is accepted:
80 80
 
81
-.. code-block:: jinja
81
+.. code-block:: twig
82 82
 
83 83
     {{ 'some text' ~ lipsum(40) ~ 'some more text' }}
84 84
 
... ...
@@ -87,7 +87,7 @@ extension point to use. And you can use it anywhere an expression is accepted:
87 87
 Last but not the least, you can also use a *global* object with a method able
88 88
 to generate lorem ipsum text:
89 89
 
90
-.. code-block:: jinja
90
+.. code-block:: twig
91 91
 
92 92
     {{ text.lipsum(40) }}
93 93
 
... ...
@@ -119,7 +119,7 @@ available in all templates and macros::
119 119
 
120 120
 You can then use the ``text`` variable anywhere in a template:
121 121
 
122
-.. code-block:: jinja
122
+.. code-block:: twig
123 123
 
124 124
     {{ text.lipsum(40) }}
125 125
 
... ...
@@ -156,7 +156,7 @@ Then, add the filter to your Twig environment::
156 156
 
157 157
 And here is how to use it in a template:
158 158
 
159
-.. code-block:: jinja
159
+.. code-block:: twig
160 160
 
161 161
     {{ 'Twig'|rot13 }}
162 162
 
... ...
@@ -168,7 +168,7 @@ to the filter (within parentheses ``()``) as extra arguments.
168 168
 
169 169
 For instance, the following code:
170 170
 
171
-.. code-block:: jinja
171
+.. code-block:: twig
172 172
 
173 173
     {{ 'TWIG'|lower }}
174 174
     {{ now|date('d/m/Y') }}
... ...
@@ -364,7 +364,7 @@ The above example shows how you can create tests that use a node class. The
364 364
 node class has access to one sub-node called 'node'. This sub-node contains the
365 365
 value that is being tested. When the ``odd`` filter is used in code such as:
366 366
 
367
-.. code-block:: jinja
367
+.. code-block:: twig
368 368
 
369 369
     {% if my_value is odd %}
370 370
 
... ...
@@ -395,14 +395,14 @@ Most of the time though, a tag is not needed:
395 395
   For instance, if you want to create a tag that converts a Markdown formatted
396 396
   text to HTML, create a ``markdown`` filter instead:
397 397
 
398
-  .. code-block:: jinja
398
+  .. code-block:: twig
399 399
 
400 400
       {{ '**markdown** text'|markdown }}
401 401
 
402 402
   If you want use this filter on large amounts of text, wrap it with the
403 403
   :doc:`apply <tags/apply>` tag:
404 404
 
405
-  .. code-block:: jinja
405
+  .. code-block:: twig
406 406
 
407 407
       {% apply markdown %}
408 408
       Title
... ...
@@ -423,7 +423,7 @@ Most of the time though, a tag is not needed:
423 423
   For instance, if you want to create a tag that logs text, create a ``log``
424 424
   function instead and call it via the :doc:`do <tags/do>` tag:
425 425
 
426
-  .. code-block:: jinja
426
+  .. code-block:: twig
427 427
 
428 428
       {% do log('Log some things') %}
429 429
 
... ...
@@ -432,7 +432,7 @@ If you still want to create a tag for a new language construct, great!
432 432
 Let's create a simple ``set`` tag that allows the definition of simple
433 433
 variables from within a template. The tag can be used like follows:
434 434
 
435
-.. code-block:: jinja
435
+.. code-block:: twig
436 436
 
437 437
     {% set name = "value" %}
438 438
 
... ...
@@ -41,7 +41,7 @@ generate).
41 41
 
42 42
 You can use a ``lipsum`` *tag*:
43 43
 
44
-.. code-block:: jinja
44
+.. code-block:: twig
45 45
 
46 46
     {% lipsum 40 %}
47 47
 
... ...
@@ -52,7 +52,7 @@ three main reasons:
52 52
 * The tag outputs something;
53 53
 * The tag is not flexible as you cannot use it in an expression:
54 54
 
55
-  .. code-block:: jinja
55
+  .. code-block:: twig
56 56
 
57 57
       {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }}
58 58
 
... ...
@@ -61,7 +61,7 @@ the most complex extension point of Twig.
61 61
 
62 62
 Now, let's use a ``lipsum`` *filter*:
63 63
 
64
-.. code-block:: jinja
64
+.. code-block:: twig
65 65
 
66 66
     {{ 40|lipsum }}
67 67
 
... ...
@@ -72,14 +72,14 @@ transform).
72 72
 
73 73
 Next, let's use a ``lipsum`` *function*:
74 74
 
75
-.. code-block:: jinja
75
+.. code-block:: twig
76 76
 
77 77
     {{ lipsum(40) }}
78 78
 
79 79
 Here we go. For this specific example, the creation of a function is the
80 80
 extension point to use. And you can use it anywhere an expression is accepted:
81 81
 
82
-.. code-block:: jinja
82
+.. code-block:: twig
83 83
 
84 84
     {{ 'some text' ~ ipsum(40) ~ 'some more text' }}
85 85
 
... ...
@@ -88,7 +88,7 @@ extension point to use. And you can use it anywhere an expression is accepted:
88 88
 Last but not the least, you can also use a *global* object with a method able
89 89
 to generate lorem ipsum text:
90 90
 
91
-.. code-block:: jinja
91
+.. code-block:: twig
92 92
 
93 93
     {{ text.lipsum(40) }}
94 94
 
... ...
@@ -120,7 +120,7 @@ available in all templates and macros::
120 120
 
121 121
 You can then use the ``text`` variable anywhere in a template:
122 122
 
123
-.. code-block:: jinja
123
+.. code-block:: twig
124 124
 
125 125
     {{ text.lipsum(40) }}
126 126
 
... ...
@@ -134,7 +134,7 @@ arguments passed to the filter (within parentheses ``()``) as extra arguments.
134 134
 Defining a filter is as easy as associating the filter name with a PHP
135 135
 callable. For instance, let's say you have the following code in a template:
136 136
 
137
-.. code-block:: jinja
137
+.. code-block:: twig
138 138
 
139 139
     {{ 'TWIG'|lower }}
140 140
 
... ...
@@ -152,7 +152,7 @@ function.
152 152
 
153 153
 A filter can also take extra arguments like in the following example:
154 154
 
155
-.. code-block:: jinja
155
+.. code-block:: twig
156 156
 
157 157
     {{ now|date('d/m/Y') }}
158 158
 
... ...
@@ -169,7 +169,7 @@ In this section, we will create a ``rot13`` filter, which should return the
169 169
 `rot13`_ transformation of a string. Here is an example of its usage and the
170 170
 expected output:
171 171
 
172
-.. code-block:: jinja
172
+.. code-block:: twig
173 173
 
174 174
     {{ "Twig"|rot13 }}
175 175
 
... ...
@@ -188,7 +188,7 @@ of the PHP function to call, here ``str_rot13``, a native PHP function.
188 188
 
189 189
 Let's say I now want to be able to add a prefix before the converted string:
190 190
 
191
-.. code-block:: jinja
191
+.. code-block:: twig
192 192
 
193 193
     {{ "Twig"|rot13('prefix_') }}
194 194
 
... ...
@@ -297,7 +297,7 @@ Functions
297 297
 A function is a regular PHP function or an object method that can be called from
298 298
 templates.
299 299
 
300
-.. code-block:: jinja
300
+.. code-block:: twig
301 301
 
302 302
     {{ constant("DATE_W3C") }}
303 303
 
... ...
@@ -368,7 +368,7 @@ feature as you need to understand how Twig's internals work.
368 368
 Let's create a simple ``set`` tag that allows the definition of simple
369 369
 variables from within a template. The tag can be used like follows:
370 370
 
371
-.. code-block:: jinja
371
+.. code-block:: twig
372 372
 
373 373
     {% set name = "value" %}
374 374
 
... ...
@@ -384,7 +384,7 @@ output escaping strategy::
384 384
 If set to ``html``, all variables in templates are escaped (using the ``html``
385 385
 escaping strategy), except those using the ``raw`` filter:
386 386
 
387
-.. code-block:: jinja
387
+.. code-block:: twig
388 388
 
389 389
     {{ article.to_html|raw }}
390 390
 
... ...
@@ -392,7 +392,7 @@ You can also change the escaping mode locally by using the ``autoescape`` tag
392 392
 (see the :doc:`autoescape<tags/autoescape>` doc for the syntax used before
393 393
 Twig 1.8):
394 394
 
395
-.. code-block:: jinja
395
+.. code-block:: twig
396 396
 
397 397
     {% autoescape 'html' %}
398 398
         {{ var }}
... ...
@@ -409,7 +409,7 @@ The escaping rules are implemented as follows:
409 409
 * Literals (integers, booleans, arrays, ...) used in the template directly as
410 410
   variables or filter arguments are never automatically escaped:
411 411
 
412
-  .. code-block:: jinja
412
+  .. code-block:: twig
413 413
 
414 414
         {{ "Twig<br />" }} {# won't be escaped #}
415 415
 
... ...
@@ -419,7 +419,7 @@ The escaping rules are implemented as follows:
419 419
 * Expressions which the result is always a literal or a variable marked safe
420 420
   are never automatically escaped:
421 421
 
422
-  .. code-block:: jinja
422
+  .. code-block:: twig
423 423
 
424 424
         {{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
425 425
 
... ...
@@ -434,13 +434,13 @@ The escaping rules are implemented as follows:
434 434
 
435 435
 * Escaping is applied before printing, after any other filter is applied:
436 436
 
437
-  .. code-block:: jinja
437
+  .. code-block:: twig
438 438
 
439 439
         {{ var|upper }} {# is equivalent to {{ var|upper|escape }} #}
440 440
 
441 441
 * The `raw` filter should only be used at the end of the filter chain:
442 442
 
443
-  .. code-block:: jinja
443
+  .. code-block:: twig
444 444
 
445 445
         {{ var|raw|upper }} {# will be escaped #}
446 446
 
... ...
@@ -451,7 +451,7 @@ The escaping rules are implemented as follows:
451 451
   ``escape('html')`` are marked safe for HTML, ``escape('js')`` is marked
452 452
   safe for JavaScript, ``raw`` is marked safe for everything.
453 453
 
454
-  .. code-block:: jinja
454
+  .. code-block:: twig
455 455
 
456 456
         {% autoescape 'js' %}
457 457
             {{ var|escape('html') }} {# will be escaped for HTML and JavaScript #}
... ...
@@ -501,7 +501,7 @@ The policy object is the first argument of the sandbox constructor::
501 501
 By default, the sandbox mode is disabled and should be enabled when including
502 502
 untrusted template code by using the ``sandbox`` tag:
503 503
 
504
-.. code-block:: jinja
504
+.. code-block:: twig
505 505
 
506 506
     {% sandbox %}
507 507
         {% include 'user.html' %}
... ...
@@ -7,7 +7,7 @@ standards:
7 7
 * Put one (and only one) space after the start of a delimiter (``{{``, ``{%``,
8 8
   and ``{#``) and before the end of a delimiter (``}}``, ``%}``, and ``#}``):
9 9
 
10
-  .. code-block:: jinja
10
+  .. code-block:: twig
11 11
 
12 12
     {{ foo }}
13 13
     {# comment #}
... ...
@@ -16,7 +16,7 @@ standards:
16 16
   When using the whitespace control character, do not put any spaces between
17 17
   it and the delimiter:
18 18
 
19
-  .. code-block:: jinja
19
+  .. code-block:: twig
20 20
 
21 21
     {{- foo -}}
22 22
     {#- comment -#}
... ...
@@ -28,7 +28,7 @@ standards:
28 28
   operators (``not``, ``and``, ``or``), ``~``, ``is``, ``in``, and the ternary
29 29
   operator (``?:``):
30 30
 
31
-  .. code-block:: jinja
31
+  .. code-block:: twig
32 32
 
33 33
      {{ 1 + 2 }}
34 34
      {{ foo ~ bar }}
... ...
@@ -37,7 +37,7 @@ standards:
37 37
 * Put one (and only one) space after the ``:`` sign in hashes and ``,`` in
38 38
   arrays and hashes:
39 39
 
40
-  .. code-block:: jinja
40
+  .. code-block:: twig
41 41
 
42 42
      {{ [1, 2, 3] }}
43 43
      {{ {'foo': 'bar'} }}
... ...
@@ -45,13 +45,13 @@ standards:
45 45
 * Do not put any spaces after an opening parenthesis and before a closing
46 46
   parenthesis in expressions:
47 47
 
48
-  .. code-block:: jinja
48
+  .. code-block:: twig
49 49
 
50 50
     {{ 1 + (2 * 3) }}
51 51
 
52 52
 * Do not put any spaces before and after string delimiters:
53 53
 
54
-  .. code-block:: jinja
54
+  .. code-block:: twig
55 55
 
56 56
     {{ 'foo' }}
57 57
     {{ "foo" }}
... ...
@@ -59,7 +59,7 @@ standards:
59 59
 * Do not put any spaces before and after the following operators: ``|``,
60 60
   ``.``, ``..``, ``[]``:
61 61
 
62
-  .. code-block:: jinja
62
+  .. code-block:: twig
63 63
 
64 64
     {{ foo|upper|lower }}
65 65
     {{ user.name }}
... ...
@@ -69,7 +69,7 @@ standards:
69 69
 * Do not put any spaces before and after the parenthesis used for filter and
70 70
   function calls:
71 71
 
72
-  .. code-block:: jinja
72
+  .. code-block:: twig
73 73
 
74 74
      {{ foo|default('foo') }}
75 75
      {{ range(1..10) }}
... ...
@@ -77,14 +77,14 @@ standards:
77 77
 * Do not put any spaces before and after the opening and the closing of arrays
78 78
   and hashes:
79 79
 
80
-  .. code-block:: jinja
80
+  .. code-block:: twig
81 81
 
82 82
      {{ [1, 2, 3] }}
83 83
      {{ {'foo': 'bar'} }}
84 84
 
85 85
 * Use lower cased and underscored variable names:
86 86
 
87
-  .. code-block:: jinja
87
+  .. code-block:: twig
88 88
 
89 89
      {% set foo = 'foo' %}
90 90
      {% set foo_bar = 'foo' %}
... ...
@@ -92,7 +92,7 @@ standards:
92 92
 * Indent your code inside tags (use the same indentation as the one used for
93 93
   the target language of the rendered template):
94 94
 
95
-  .. code-block:: jinja
95
+  .. code-block:: twig
96 96
 
97 97
      {% block foo %}
98 98
          {% if true %}
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``abs`` filter returns the absolute value.
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {# number = -5 #}
9 9
 
... ...
@@ -8,7 +8,7 @@ The ``batch`` filter "batches" items by returning a list of lists with the
8 8
 given number of items. A second parameter can be provided and used to fill in
9 9
 missing items:
10 10
 
11
-.. code-block:: jinja
11
+.. code-block:: twig
12 12
 
13 13
     {% set items = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] %}
14 14
 
... ...
@@ -24,7 +24,7 @@ missing items:
24 24
 
25 25
 The above example will be rendered as:
26 26
 
27
-.. code-block:: jinja
27
+.. code-block:: twig
28 28
 
29 29
     <table>
30 30
         <tr>
... ...
@@ -4,7 +4,7 @@
4 4
 The ``capitalize`` filter capitalizes a value. The first character will be
5 5
 uppercase, all others lowercase:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {{ 'my first car'|capitalize }}
10 10
 
... ...
@@ -8,7 +8,7 @@ The ``convert_encoding`` filter converts a string from one encoding to
8 8
 another. The first argument is the expected output charset and the second one
9 9
 is the input charset:
10 10
 
11
-.. code-block:: jinja
11
+.. code-block:: twig
12 12
 
13 13
     {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }}
14 14
 
... ...
@@ -15,7 +15,7 @@
15 15
 
16 16
 The ``date`` filter formats a date to a given format:
17 17
 
18
-.. code-block:: jinja
18
+.. code-block:: twig
19 19
 
20 20
     {{ post.published_at|date("m/d/Y") }}
21 21
 
... ...
@@ -27,14 +27,14 @@ The ``date`` filter accepts strings (it must be in a format supported by the
27 27
 `strtotime`_ function), `DateTime`_ instances, or `DateInterval`_ instances. For
28 28
 instance, to display the current date, filter the word "now":
29 29
 
30
-.. code-block:: jinja
30
+.. code-block:: twig
31 31
 
32 32
     {{ "now"|date("m/d/Y") }}
33 33
 
34 34
 To escape words and characters in the date format use ``\\`` in front of each
35 35
 character:
36 36
 
37
-.. code-block:: jinja
37
+.. code-block:: twig
38 38
 
39 39
     {{ post.published_at|date("F jS \\a\\t g:ia") }}
40 40
 
... ...
@@ -42,7 +42,7 @@ If the value passed to the ``date`` filter is ``null``, it will return the
42 42
 current date by default. If an empty string is desired instead of the current
43 43
 date, use a ternary operator:
44 44
 
45
-.. code-block:: jinja
45
+.. code-block:: twig
46 46
 
47 47
     {{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}
48 48
 
... ...
@@ -66,14 +66,14 @@ By default, the date is displayed by applying the default timezone (the one
66 66
 specified in php.ini or declared in Twig -- see below), but you can override
67 67
 it by explicitly specifying a timezone:
68 68
 
69
-.. code-block:: jinja
69
+.. code-block:: twig
70 70
 
71 71
     {{ post.published_at|date("m/d/Y", "Europe/Paris") }}
72 72
 
73 73
 If the date is already a DateTime object, and if you want to keep its current
74 74
 timezone, pass ``false`` as the timezone value:
75 75
 
76
-.. code-block:: jinja
76
+.. code-block:: twig
77 77
 
78 78
     {{ post.published_at|date("m/d/Y", false) }}
79 79
 
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``date_modify`` filter modifies a date with a given modifier string:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {{ post.published_at|date_modify("+1 day")|date("m/d/Y") }}
12 12
 
... ...
@@ -4,7 +4,7 @@
4 4
 The ``default`` filter returns the passed default value if the value is
5 5
 undefined or empty, otherwise the value of the variable:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {{ var|default('var is not defined') }}
10 10
 
... ...
@@ -18,7 +18,7 @@ When using the ``default`` filter on an expression that uses variables in some
18 18
 method calls, be sure to use the ``default`` filter whenever a variable can be
19 19
 undefined:
20 20
 
21
-.. code-block:: jinja
21
+.. code-block:: twig
22 22
 
23 23
     {{ var.method(foo|default('foo'))|default('foo') }}
24 24
 
... ...
@@ -13,7 +13,7 @@ context.
13 13
 
14 14
 By default, it uses the HTML escaping strategy:
15 15
 
16
-.. code-block:: html+jinja
16
+.. code-block:: html+twig
17 17
 
18 18
     <p>
19 19
         {{ user.username|escape }}
... ...
@@ -21,7 +21,7 @@ By default, it uses the HTML escaping strategy:
21 21
 
22 22
 For convenience, the ``e`` filter is defined as an alias:
23 23
 
24
-.. code-block:: html+jinja
24
+.. code-block:: html+twig
25 25
 
26 26
     <p>
27 27
         {{ user.username|e }}
... ...
@@ -30,7 +30,7 @@ For convenience, the ``e`` filter is defined as an alias:
30 30
 The ``escape`` filter can also be used in other contexts than HTML thanks to
31 31
 an optional argument which defines the escaping strategy to use:
32 32
 
33
-.. code-block:: jinja
33
+.. code-block:: twig
34 34
 
35 35
     {{ user.username|e }}
36 36
     {# is equivalent to #}
... ...
@@ -38,7 +38,7 @@ an optional argument which defines the escaping strategy to use:
38 38
 
39 39
 And here is how to escape variables included in JavaScript code:
40 40
 
41
-.. code-block:: jinja
41
+.. code-block:: twig
42 42
 
43 43
     {{ user.username|escape('js') }}
44 44
     {{ user.username|e('js') }}
... ...
@@ -77,7 +77,7 @@ to learn more about this topic.
77 77
     escape filter; but that does not work when using a variable as the
78 78
     escaping strategy:
79 79
 
80
-    .. code-block:: jinja
80
+    .. code-block:: twig
81 81
 
82 82
         {% set strategy = 'html' %}
83 83
 
... ...
@@ -89,7 +89,7 @@ to learn more about this topic.
89 89
     When using a variable as the escaping strategy, you should disable
90 90
     automatic escaping:
91 91
 
92
-    .. code-block:: jinja
92
+    .. code-block:: twig
93 93
 
94 94
         {% set strategy = 'html' %}
95 95
 
... ...
@@ -7,7 +7,7 @@
7 7
 The ``first`` filter returns the first "element" of a sequence, a mapping, or
8 8
 a string:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {{ [1, 2, 3, 4]|first }}
13 13
     {# outputs 1 #}
... ...
@@ -4,7 +4,7 @@
4 4
 The ``format`` filter formats a given string by replacing the placeholders
5 5
 (placeholders follows the `sprintf`_ notation):
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {{ "I like %s and %s."|format(foo, "bar") }}
10 10
 
... ...
@@ -7,7 +7,7 @@
7 7
 The ``join`` filter returns a string which is the concatenation of the items
8 8
 of a sequence:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {{ [1, 2, 3]|join }}
13 13
     {# returns 123 #}
... ...
@@ -15,7 +15,7 @@ of a sequence:
15 15
 The separator between elements is an empty string per default, but you can
16 16
 define it with the optional first parameter:
17 17
 
18
-.. code-block:: jinja
18
+.. code-block:: twig
19 19
 
20 20
     {{ [1, 2, 3]|join('|') }}
21 21
     {# outputs 1|2|3 #}
... ...
@@ -23,7 +23,7 @@ define it with the optional first parameter:
23 23
 A second parameter can also be provided that will be the separator used between
24 24
 the last two items of the sequence:
25 25
 
26
-.. code-block:: jinja
26
+.. code-block:: twig
27 27
 
28 28
     {{ [1, 2, 3]|join(', ', ' and ') }}
29 29
     {# outputs 1, 2 and 3 #}
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``json_encode`` filter returns the JSON representation of a value:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {{ data|json_encode() }}
9 9
 
... ...
@@ -4,7 +4,7 @@
4 4
 The ``keys`` filter returns the keys of an array. It is useful when you want to
5 5
 iterate over the keys of an array:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {% for key in array|keys %}
10 10
         ...
... ...
@@ -7,7 +7,7 @@
7 7
 The ``last`` filter returns the last "element" of a sequence, a mapping, or
8 8
 a string:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {{ [1, 2, 3, 4]|last }}
13 13
     {# outputs 4 #}
... ...
@@ -16,7 +16,7 @@ it will return the length of the string provided by that method.
16 16
 
17 17
 For objects that implement the ``IteratorAggregate`` interface, ``length`` will use the return value of the ``iterator_count()`` method.
18 18
 
19
-.. code-block:: jinja
19
+.. code-block:: twig
20 20
 
21 21
     {% if users|length > 10 %}
22 22
         ...
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``lower`` filter converts a value to lowercase:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {{ 'WELCOME'|lower }}
9 9
 
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``merge`` filter merges an array with another array:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {% set values = [1, 2] %}
9 9
 
... ...
@@ -15,7 +15,7 @@ New values are added at the end of the existing ones.
15 15
 
16 16
 The ``merge`` filter also works on hashes:
17 17
 
18
-.. code-block:: jinja
18
+.. code-block:: twig
19 19
 
20 20
     {% set items = { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'unknown' } %}
21 21
 
... ...
@@ -32,7 +32,7 @@ overridden.
32 32
     If you want to ensure that some values are defined in an array (by given
33 33
     default values), reverse the two elements in the call:
34 34
 
35
-    .. code-block:: jinja
35
+    .. code-block:: twig
36 36
 
37 37
         {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
38 38
 
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``nl2br`` filter inserts HTML line breaks before all newlines in a string:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {{ "I like Twig.\nYou will like it too."|nl2br }}
12 12
     {# outputs
... ...
@@ -7,21 +7,21 @@
7 7
 The ``number_format`` filter formats numbers.  It is a wrapper around PHP's
8 8
 `number_format`_ function:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {{ 200.35|number_format }}
13 13
 
14 14
 You can control the number of decimal places, decimal point, and thousands
15 15
 separator using the additional arguments:
16 16
 
17
-.. code-block:: jinja
17
+.. code-block:: twig
18 18
 
19 19
     {{ 9800.333|number_format(2, '.', ',') }}
20 20
 
21 21
 To format negative numbers, wrap the number with parentheses (needed because of
22 22
 Twig's :ref:`precedence of operators <twig-expressions>`:
23 23
 
24
-.. code-block:: jinja
24
+.. code-block:: twig
25 25
 
26 26
     {{ -9800.333|number_format(2, '.', ',') }} {# outputs : -9 #}
27 27
     {{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9,800.33 #}
... ...
@@ -5,7 +5,7 @@ The ``raw`` filter marks the value as being "safe", which means that in an
5 5
 environment with automatic escaping enabled this variable will not be escaped
6 6
 if ``raw`` is the last filter applied to it:
7 7
 
8
-.. code-block:: jinja
8
+.. code-block:: twig
9 9
 
10 10
     {% autoescape %}
11 11
         {{ var|raw }} {# var won't be escaped #}
... ...
@@ -17,7 +17,7 @@ if ``raw`` is the last filter applied to it:
17 17
 
18 18
     Be careful when using the ``raw`` filter inside expressions:
19 19
 
20
-    .. code-block:: jinja
20
+    .. code-block:: twig
21 21
 
22 22
         {% autoescape %}
23 23
             {% set hello = '<strong>Hello</strong>' %}
... ...
@@ -4,7 +4,7 @@
4 4
 The ``replace`` filter formats a given string by replacing the placeholders
5 5
 (placeholders are free-form):
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }}
10 10
 
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``reverse`` filter reverses a sequence, a mapping, or a string:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {% for user in users|reverse %}
12 12
         ...
... ...
@@ -21,7 +21,7 @@ The ``reverse`` filter reverses a sequence, a mapping, or a string:
21 21
     For sequences and mappings, numeric keys are not preserved. To reverse
22 22
     them as well, pass ``true`` as an argument to the ``reverse`` filter:
23 23
 
24
-    .. code-block:: jinja
24
+    .. code-block:: twig
25 25
 
26 26
         {% for key, value in {1: "a", 2: "b", 3: "c"}|reverse %}
27 27
             {{ key }}: {{ value }}
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``round`` filter rounds a number to a given precision:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {{ 42.55|round }}
12 12
     {# outputs 43 #}
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``slice`` filter extracts a slice of a sequence, a mapping, or a string:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {% for i in [1, 2, 3, 4, 5]|slice(1, 2) %}
12 12
         {# will iterate over 2 and 3 #}
... ...
@@ -18,7 +18,7 @@ The ``slice`` filter extracts a slice of a sequence, a mapping, or a string:
18 18
 
19 19
 You can use any valid expression for both the start and the length:
20 20
 
21
-.. code-block:: jinja
21
+.. code-block:: twig
22 22
 
23 23
     {% for i in [1, 2, 3, 4, 5]|slice(start, length) %}
24 24
         {# ... #}
... ...
@@ -26,7 +26,7 @@ You can use any valid expression for both the start and the length:
26 26
 
27 27
 As syntactic sugar, you can also use the ``[]`` notation:
28 28
 
29
-.. code-block:: jinja
29
+.. code-block:: twig
30 30
 
31 31
     {% for i in [1, 2, 3, 4, 5][start:length] %}
32 32
         {# ... #}
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``sort`` filter sorts an array:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {% for user in users|sort %}
9 9
         ...
... ...
@@ -8,7 +8,7 @@
8 8
 Use the ``spaceless`` filter to remove whitespace *between HTML tags*, not
9 9
 whitespace within HTML tags or whitespace in plain text:
10 10
 
11
-.. code-block:: jinja
11
+.. code-block:: twig
12 12
 
13 13
     {{
14 14
         "<div>
... ...
@@ -21,7 +21,7 @@ whitespace within HTML tags or whitespace in plain text:
21 21
 You can combine ``spaceless`` with the ``apply`` tag to apply the transformation
22 22
 on large amounts of HTML:
23 23
 
24
-.. code-block:: jinja
24
+.. code-block:: twig
25 25
 
26 26
     {% apply spaceless %}
27 27
         <div>
... ...
@@ -7,7 +7,7 @@
7 7
 The ``split`` filter splits a string by the given delimiter and returns a list
8 8
 of strings:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {% set foo = "one,two,three"|split(',') %}
13 13
     {# foo contains ['one', 'two', 'three'] #}
... ...
@@ -22,7 +22,7 @@ You can also pass a ``limit`` argument:
22 22
 
23 23
 * If ``limit`` is zero, then this is treated as 1.
24 24
 
25
-.. code-block:: jinja
25
+.. code-block:: twig
26 26
 
27 27
     {% set foo = "one,two,three,four,five"|split(',', 3) %}
28 28
     {# foo contains ['one', 'two', 'three,four,five'] #}
... ...
@@ -30,7 +30,7 @@ You can also pass a ``limit`` argument:
30 30
 If the ``delimiter`` is an empty string, then value will be split by equal
31 31
 chunks. Length is set by the ``limit`` argument (one character by default).
32 32
 
33
-.. code-block:: jinja
33
+.. code-block:: twig
34 34
 
35 35
     {% set foo = "123"|split('') %}
36 36
     {# foo contains ['1', '2', '3'] #}
... ...
@@ -4,13 +4,13 @@
4 4
 The ``striptags`` filter strips SGML/XML tags and replace adjacent whitespace
5 5
 by one space:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {{ some_html|striptags }}
10 10
 
11 11
 You can also provide tags which should not be stripped:
12 12
 
13
-.. code-block:: jinja
13
+.. code-block:: twig
14 14
 
15 15
     {{ some_html|striptags('<br><p>') }}
16 16
 
... ...
@@ -4,7 +4,7 @@
4 4
 The ``title`` filter returns a titlecased version of the value. Words will
5 5
 start with uppercase letters, all remaining characters are lowercase:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {{ 'my first car'|title }}
10 10
 
... ...
@@ -10,7 +10,7 @@
10 10
 The ``trim`` filter strips whitespace (or other characters) from the beginning
11 11
 and end of a string:
12 12
 
13
-.. code-block:: jinja
13
+.. code-block:: twig
14 14
 
15 15
     {{ '  I like Twig.  '|trim }}
16 16
 
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``upper`` filter converts a value to uppercase:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {{ 'welcome'|upper }}
9 9
 
... ...
@@ -11,7 +11,7 @@
11 11
 The ``url_encode`` filter percent encodes a given string as URL segment
12 12
 or an array as query string:
13 13
 
14
-.. code-block:: jinja
14
+.. code-block:: twig
15 15
 
16 16
     {{ "path-seg*ment"|url_encode }}
17 17
     {# outputs "path-seg%2Ament" #}
... ...
@@ -7,7 +7,7 @@
7 7
 The ``attribute`` function can be used to access a "dynamic" attribute of a
8 8
 variable:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {{ attribute(object, method) }}
13 13
     {{ attribute(object, method, arguments) }}
... ...
@@ -16,7 +16,7 @@ variable:
16 16
 In addition, the ``defined`` test can check for the existence of a dynamic
17 17
 attribute:
18 18
 
19
-.. code-block:: jinja
19
+.. code-block:: twig
20 20
 
21 21
     {{ attribute(object, method) is defined ? 'Method exists' : 'Method does not exist' }}
22 22
 
... ...
@@ -10,7 +10,7 @@
10 10
 When a template uses inheritance and if you want to print a block multiple
11 11
 times, use the ``block`` function:
12 12
 
13
-.. code-block:: jinja
13
+.. code-block:: twig
14 14
 
15 15
     <title>{% block title %}{% endblock %}</title>
16 16
 
... ...
@@ -21,14 +21,14 @@ times, use the ``block`` function:
21 21
 The ``block`` function can also be used to display one block from another
22 22
 template:
23 23
 
24
-.. code-block:: jinja
24
+.. code-block:: twig
25 25
 
26 26
     {{ block("title", "common_blocks.twig") }}
27 27
 
28 28
 Use the ``defined`` test to check if a block exists in the context of the
29 29
 current template:
30 30
 
31
-.. code-block:: jinja
31
+.. code-block:: twig
32 32
 
33 33
     {% if block("footer") is defined %}
34 34
         ...
... ...
@@ -9,20 +9,20 @@
9 9
 
10 10
 ``constant`` returns the constant value for a given string:
11 11
 
12
-.. code-block:: jinja
12
+.. code-block:: twig
13 13
 
14 14
     {{ some_date|date(constant('DATE_W3C')) }}
15 15
     {{ constant('Namespace\\Classname::CONSTANT_NAME') }}
16 16
 
17 17
 As of 1.12.1 you can read constants from object instances as well:
18 18
 
19
-.. code-block:: jinja
19
+.. code-block:: twig
20 20
 
21 21
     {{ constant('RSS', date) }}
22 22
 
23 23
 Use the ``defined`` test to check if a constant is defined:
24 24
 
25
-.. code-block:: jinja
25
+.. code-block:: twig
26 26
 
27 27
     {% if constant('SOME_CONST') is defined %}
28 28
         ...
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 The ``cycle`` function cycles on an array of values:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {% set start_year = date() | date('Y') %}
9 9
     {% set end_year = start_year + 5 %}
... ...
@@ -14,7 +14,7 @@ The ``cycle`` function cycles on an array of values:
14 14
 
15 15
 The array can contain any number of values:
16 16
 
17
-.. code-block:: jinja
17
+.. code-block:: twig
18 18
 
19 19
     {% set fruits = ['apple', 'orange', 'citrus'] %}
20 20
 
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 Converts an argument to a date to allow date comparison:
11 11
 
12
-.. code-block:: jinja
12
+.. code-block:: twig
13 13
 
14 14
     {% if date(user.created_at) < date('-2days') %}
15 15
         {# do something #}
... ...
@@ -19,7 +19,7 @@ The argument must be in one of PHP’s supported `date and time formats`_.
19 19
 
20 20
 You can pass a timezone as the second argument:
21 21
 
22
-.. code-block:: jinja
22
+.. code-block:: twig
23 23
 
24 24
     {% if date(user.created_at) < date('-2days', 'Europe/Paris') %}
25 25
         {# do something #}
... ...
@@ -27,7 +27,7 @@ You can pass a timezone as the second argument:
27 27
 
28 28
 If no argument is passed, the function returns the current date:
29 29
 
30
-.. code-block:: jinja
30
+.. code-block:: twig
31 31
 
32 32
     {% if date(user.created_at) < date() %}
33 33
         {# always! #}
... ...
@@ -8,7 +8,7 @@ The ``dump`` function dumps information about a template variable. This is
8 8
 mostly useful to debug a template that does not behave as expected by
9 9
 introspecting its variables:
10 10
 
11
-.. code-block:: jinja
11
+.. code-block:: twig
12 12
 
13 13
     {{ dump(user) }}
14 14
 
... ...
@@ -31,7 +31,7 @@ introspecting its variables:
31 31
 In an HTML context, wrap the output with a ``pre`` tag to make it easier to
32 32
 read:
33 33
 
34
-.. code-block:: jinja
34
+.. code-block:: twig
35 35
 
36 36
     <pre>
37 37
         {{ dump(user) }}
... ...
@@ -45,14 +45,14 @@ read:
45 45
 
46 46
 You can debug several variables by passing them as additional arguments:
47 47
 
48
-.. code-block:: jinja
48
+.. code-block:: twig
49 49
 
50 50
     {{ dump(user, categories) }}
51 51
 
52 52
 If you don't pass any value, all variables from the current context are
53 53
 dumped:
54 54
 
55
-.. code-block:: jinja
55
+.. code-block:: twig
56 56
 
57 57
     {{ dump() }}
58 58
 
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``include`` function returns the rendered content of a template:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {{ include('template.html') }}
12 12
     {{ include(some_var) }}
... ...
@@ -19,7 +19,7 @@ paths defined by it.
19 19
 The context is passed by default to the template but you can also pass
20 20
 additional variables:
21 21
 
22
-.. code-block:: jinja
22
+.. code-block:: twig
23 23
 
24 24
     {# template.html will have access to the variables from the current context and the additional ones provided #}
25 25
     {{ include('template.html', {foo: 'bar'}) }}
... ...
@@ -27,12 +27,12 @@ additional variables:
27 27
 You can disable access to the context by setting ``with_context`` to
28 28
 ``false``:
29 29
 
30
-.. code-block:: jinja
30
+.. code-block:: twig
31 31
 
32 32
     {# only the foo variable will be accessible #}
33 33
     {{ include('template.html', {foo: 'bar'}, with_context = false) }}
34 34
 
35
-.. code-block:: jinja
35
+.. code-block:: twig
36 36
 
37 37
     {# no variables will be accessible #}
38 38
     {{ include('template.html', with_context = false) }}
... ...
@@ -53,14 +53,14 @@ And if the expression evaluates to a ``\Twig\Template`` or a
53 53
 When you set the ``ignore_missing`` flag, Twig will return an empty string if
54 54
 the template does not exist:
55 55
 
56
-.. code-block:: jinja
56
+.. code-block:: twig
57 57
 
58 58
     {{ include('sidebar.html', ignore_missing = true) }}
59 59
 
60 60
 You can also provide a list of templates that are checked for existence before
61 61
 inclusion. The first template that exists will be rendered:
62 62
 
63
-.. code-block:: jinja
63
+.. code-block:: twig
64 64
 
65 65
     {{ include(['page_detailed.html', 'page.html']) }}
66 66
 
... ...
@@ -70,7 +70,7 @@ of the templates exist, otherwise it will throw an exception.
70 70
 When including a template created by an end user, you should consider
71 71
 sandboxing it:
72 72
 
73
-.. code-block:: jinja
73
+.. code-block:: twig
74 74
 
75 75
     {{ include('page.html', sandboxed = true) }}
76 76
 
... ...
@@ -6,14 +6,14 @@
6 6
 
7 7
 ``max`` returns the biggest value of a sequence or a set of values:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {{ max(1, 3, 2) }}
12 12
     {{ max([1, 3, 2]) }}
13 13
 
14 14
 When called with a mapping, max ignores keys and only compares values:
15 15
 
16
-.. code-block:: jinja
16
+.. code-block:: twig
17 17
 
18 18
     {{ max({2: "e", 1: "a", 3: "b", 5: "d", 4: "c"}) }}
19 19
     {# returns "e" #}
... ...
@@ -6,14 +6,14 @@
6 6
 
7 7
 ``min`` returns the lowest value of a sequence or a set of values:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {{ min(1, 3, 2) }}
12 12
     {{ min([1, 3, 2]) }}
13 13
 
14 14
 When called with a mapping, min ignores keys and only compares values:
15 15
 
16
-.. code-block:: jinja
16
+.. code-block:: twig
17 17
 
18 18
     {{ min({2: "e", 3: "a", 1: "b", 5: "d", 4: "c"}) }}
19 19
     {# returns "a" #}
... ...
@@ -4,7 +4,7 @@
4 4
 When a template uses inheritance, it's possible to render the contents of the
5 5
 parent block when overriding a block by using the ``parent`` function:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {% extends "base.html" %}
10 10
 
... ...
@@ -19,7 +19,7 @@ parameter type:
19 19
 * a random integer between the integer parameter (when negative) and 0 (inclusive).
20 20
 * a random integer between the first integer and the second integer parameter (inclusive).
21 21
 
22
-.. code-block:: jinja
22
+.. code-block:: twig
23 23
 
24 24
     {{ random(['apple', 'orange', 'citrus']) }} {# example output: orange #}
25 25
     {{ random('ABC') }}                         {# example output: C #}
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 Returns a list containing an arithmetic progression of integers:
5 5
 
6
-.. code-block:: jinja
6
+.. code-block:: twig
7 7
 
8 8
     {% for i in range(0, 3) %}
9 9
         {{ i }},
... ...
@@ -14,7 +14,7 @@ Returns a list containing an arithmetic progression of integers:
14 14
 When step is given (as the third parameter), it specifies the increment (or
15 15
 decrement for negative values):
16 16
 
17
-.. code-block:: jinja
17
+.. code-block:: twig
18 18
 
19 19
     {% for i in range(0, 6, 2) %}
20 20
         {{ i }},
... ...
@@ -27,7 +27,7 @@ decrement for negative values):
27 27
     Note that if the start is greater than the end, ``range`` assumes a step of
28 28
     ``-1``:
29 29
 
30
-    .. code-block:: jinja
30
+    .. code-block:: twig
31 31
 
32 32
         {% for i in range(3, 0) %}
33 33
             {{ i }},
... ...
@@ -38,7 +38,7 @@ decrement for negative values):
38 38
 The Twig built-in ``..`` operator is just syntactic sugar for the ``range``
39 39
 function (with a step of ``1``, or ``-1`` if the start is greater than the end):
40 40
 
41
-.. code-block:: jinja
41
+.. code-block:: twig
42 42
 
43 43
     {% for i in 0..3 %}
44 44
         {{ i }},
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 The ``source`` function returns the content of a template without rendering it:
11 11
 
12
-.. code-block:: jinja
12
+.. code-block:: twig
13 13
 
14 14
     {{ source('template.html') }}
15 15
     {{ source(some_var) }}
... ...
@@ -17,7 +17,7 @@ The ``source`` function returns the content of a template without rendering it:
17 17
 When you set the ``ignore_missing`` flag, Twig will return an empty string if
18 18
 the template does not exist:
19 19
 
20
-.. code-block:: jinja
20
+.. code-block:: twig
21 21
 
22 22
     {{ source('template.html', ignore_missing = true) }}
23 23
 
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 The ``template_from_string`` function loads a template from a string:
11 11
 
12
-.. code-block:: jinja
12
+.. code-block:: twig
13 13
 
14 14
     {{ include(template_from_string("Hello {{ name }}")) }}
15 15
     {{ include(template_from_string(page.template)) }}
... ...
@@ -17,7 +17,7 @@ The ``template_from_string`` function loads a template from a string:
17 17
 To ease debugging, you can also give the template a name that will be part of
18 18
 any related error message:
19 19
 
20
-.. code-block:: jinja
20
+.. code-block:: twig
21 21
 
22 22
     {{ include(template_from_string(page.template, "template for page " ~ page.name)) }}
23 23
 
... ...
@@ -67,7 +67,7 @@ and sometimes decorated with a layout. As Twig layout template names can be
67 67
 any valid expression, you can pass a variable that evaluates to ``true`` when
68 68
 the request is made via Ajax and choose the layout accordingly:
69 69
 
70
-.. code-block:: jinja
70
+.. code-block:: twig
71 71
 
72 72
     {% extends request.ajax ? "base_ajax.html" : "base.html" %}
73 73
 
... ...
@@ -81,7 +81,7 @@ Making an Include dynamic
81 81
 When including a template, its name does not need to be a string. For
82 82
 instance, the name can depend on the value of a variable:
83 83
 
84
-.. code-block:: jinja
84
+.. code-block:: twig
85 85
 
86 86
     {% include var ~ '_foo.html' %}
87 87
 
... ...
@@ -91,7 +91,7 @@ rendered.
91 91
 As a matter of fact, the template name can be any valid expression, such as
92 92
 the following:
93 93
 
94
-.. code-block:: jinja
94
+.. code-block:: twig
95 95
 
96 96
     {% include var|default('index') ~ '_foo.html' %}
97 97
 
... ...
@@ -114,7 +114,7 @@ Let's say that your templates are loaded from both ``.../templates/mysite``
114 114
 and ``.../templates/default`` in this order. The ``page.twig`` template,
115 115
 stored in ``.../templates/default`` reads as follows:
116 116
 
117
-.. code-block:: jinja
117
+.. code-block:: twig
118 118
 
119 119
     {# page.twig #}
120 120
     {% extends "layout.twig" %}
... ...
@@ -126,7 +126,7 @@ You can replace this template by putting a file with the same name in
126 126
 ``.../templates/mysite``. And if you want to extend the original template, you
127 127
 might be tempted to write the following:
128 128
 
129
-.. code-block:: jinja
129
+.. code-block:: twig
130 130
 
131 131
     {# page.twig in .../templates/mysite #}
132 132
     {% extends "page.twig" %} {# from .../templates/default #}
... ...
@@ -142,7 +142,7 @@ time you will use the "normal" paths, but in the special case of wanting to
142 142
 extend a template with an overriding version of itself we can reference its
143 143
 parent's full, unambiguous template path in the extends tag:
144 144
 
145
-.. code-block:: jinja
145
+.. code-block:: twig
146 146
 
147 147
     {# page.twig in .../templates/mysite #}
148 148
     {% extends "default/page.twig" %} {# from .../templates #}
... ...
@@ -242,7 +242,7 @@ instance, if you have the following template data::
242 242
 
243 243
 And the following template to display all messages in all topics:
244 244
 
245
-.. code-block:: jinja
245
+.. code-block:: twig
246 246
 
247 247
     {% for topic, messages in topics %}
248 248
         * {{ loop.index }}: {{ topic }}
... ...
@@ -515,7 +515,7 @@ From a template, you can easily load a template stored in a string via the
515 515
 ``template_from_string`` function (available as of Twig 1.11 via the
516 516
 ``\Twig\Extension\StringLoaderExtension`` extension):
517 517
 
518
-.. code-block:: jinja
518
+.. code-block:: twig
519 519
 
520 520
     {{ include(template_from_string("Hello {{ name }}")) }}
521 521
 
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 The ``apply`` tag allows you to apply Twig filters on a block of template data:
8 8
 
9
-.. code-block:: jinja
9
+.. code-block:: twig
10 10
 
11 11
     {% apply upper %}
12 12
         This text becomes uppercase
... ...
@@ -14,7 +14,7 @@ The ``apply`` tag allows you to apply Twig filters on a block of template data:
14 14
 
15 15
 You can also chain filters and pass arguments to them:
16 16
 
17
-.. code-block:: jinja
17
+.. code-block:: twig
18 18
 
19 19
     {% apply lower|escape('html') %}
20 20
         <strong>SOME TEXT</strong>
... ...
@@ -4,7 +4,7 @@
4 4
 Whether automatic escaping is enabled or not, you can mark a section of a
5 5
 template to be escaped or not by using the ``autoescape`` tag:
6 6
 
7
-.. code-block:: jinja
7
+.. code-block:: twig
8 8
 
9 9
     {% autoescape %}
10 10
         Everything will be automatically escaped in this block
... ...
@@ -29,7 +29,7 @@ template to be escaped or not by using the ``autoescape`` tag:
29 29
 
30 30
     Before Twig 1.8, the syntax was different:
31 31
 
32
-    .. code-block:: jinja
32
+    .. code-block:: twig
33 33
 
34 34
         {% autoescape true %}
35 35
             Everything will be automatically escaped in this block
... ...
@@ -49,7 +49,7 @@ When automatic escaping is enabled everything is escaped by default except for
49 49
 values explicitly marked as safe. Those can be marked in the template by using
50 50
 the :doc:`raw<../filters/raw>` filter:
51 51
 
52
-.. code-block:: jinja
52
+.. code-block:: twig
53 53
 
54 54
     {% autoescape %}
55 55
         {{ safe_value|raw }}
... ...
@@ -67,7 +67,7 @@ Functions returning template data (like :doc:`macros<macro>` and
67 67
 
68 68
     Twig does not escape static expressions:
69 69
 
70
-    .. code-block:: jinja
70
+    .. code-block:: twig
71 71
 
72 72
         {% set hello = "<strong>Hello</strong>" %}
73 73
         {{ hello }}
... ...
@@ -7,7 +7,7 @@
7 7
 Twig generates a deprecation notice (via a call to the ``trigger_error()``
8 8
 PHP function) where the ``deprecated`` tag is used in a template:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {# base.twig #}
13 13
     {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
... ...
@@ -15,7 +15,7 @@ PHP function) where the ``deprecated`` tag is used in a template:
15 15
 
16 16
 Also you can deprecate a block in the following way:
17 17
 
18
-.. code-block:: jinja
18
+.. code-block:: twig
19 19
 
20 20
     {% block hey %}
21 21
         {% deprecated 'The "hey" block is deprecated, use "greet" instead.' %}
... ...
@@ -7,6 +7,6 @@
7 7
 The ``do`` tag works exactly like the regular variable expression (``{{ ...
8 8
 }}``) just that it doesn't print anything:
9 9
 
10
-.. code-block:: jinja
10
+.. code-block:: twig
11 11
 
12 12
     {% do 1 + 2 %}
... ...
@@ -12,7 +12,7 @@ included template, like when extending a template.
12 12
 
13 13
 Think of an embedded template as a "micro layout skeleton".
14 14
 
15
-.. code-block:: jinja
15
+.. code-block:: twig
16 16
 
17 17
     {% embed "teasers_skeleton.twig" %}
18 18
         {# These blocks are defined in "teasers_skeleton.twig" #}
... ...
@@ -116,7 +116,7 @@ as necessary:
116 116
 
117 117
 Page template ``foo.twig``:
118 118
 
119
-.. code-block:: jinja
119
+.. code-block:: twig
120 120
 
121 121
     {% extends "layout_skeleton.twig" %}
122 122
 
... ...
@@ -134,7 +134,7 @@ Page template ``foo.twig``:
134 134
 
135 135
 And here is the code for ``vertical_boxes_skeleton.twig``:
136 136
 
137
-.. code-block:: html+jinja
137
+.. code-block:: html+twig
138 138
 
139 139
     <div class="top_box">
140 </