This file is indexed.

/usr/share/doc/python-jinja2-doc/html/extensions.html is in python-jinja2-doc 2.8-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Extensions &mdash; Jinja2 2.7.3 documentation</title>
    
    <link rel="stylesheet" href="_static/jinja.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.7.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Jinja2 2.7.3 documentation" href="index.html" />
    <link rel="next" title="Integration" href="integration.html" />
    <link rel="prev" title="Template Designer Documentation" href="templates.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="integration.html" title="Integration"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="templates.html" title="Template Designer Documentation"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Jinja2 2.7.3 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="extensions">
<span id="jinja-extensions"></span><h1>Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline"></a></h1>
<p>Jinja2 supports extensions that can add extra filters, tests, globals or even
extend the parser.  The main motivation of extensions is to move often used
code into a reusable class like adding support for internationalization.</p>
<div class="section" id="adding-extensions">
<h2>Adding Extensions<a class="headerlink" href="#adding-extensions" title="Permalink to this headline"></a></h2>
<p>Extensions are added to the Jinja2 environment at creation time.  Once the
environment is created additional extensions cannot be added.  To add an
extension pass a list of extension classes or import paths to the
<cite>extensions</cite> parameter of the <tt class="xref py py-class docutils literal"><span class="pre">Environment</span></tt> constructor.  The following
example creates a Jinja2 environment with the i18n extension loaded:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">jinja_env</span> <span class="o">=</span> <span class="n">Environment</span><span class="p">(</span><span class="n">extensions</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;jinja2.ext.i18n&#39;</span><span class="p">])</span>
</pre></div>
</div>
</div>
<div class="section" id="i18n-extension">
<span id="id1"></span><h2>i18n Extension<a class="headerlink" href="#i18n-extension" title="Permalink to this headline"></a></h2>
<p><strong>Import name:</strong> <cite>jinja2.ext.i18n</cite></p>
<p>The i18n extension can be used in combination with <a class="reference external" href="http://docs.python.org/dev/library/gettext">gettext</a> or <a class="reference external" href="http://babel.edgewall.org/">babel</a>.  If
the i18n extension is enabled Jinja2 provides a <cite>trans</cite> statement that marks
the wrapped string as translatable and calls <cite>gettext</cite>.</p>
<p>After enabling, dummy <cite>_</cite> function that forwards calls to <cite>gettext</cite> is added
to the environment globals.  An internationalized application then has to
provide a <cite>gettext</cite> function and optionally an <cite>ngettext</cite> function into the
namespace, either globally or for each rendering.</p>
<div class="section" id="environment-methods">
<h3>Environment Methods<a class="headerlink" href="#environment-methods" title="Permalink to this headline"></a></h3>
<p>After enabling the extension, the environment provides the following
additional methods:</p>
<dl class="method">
<dt id="jinja2.Environment.install_gettext_translations">
<tt class="descclassname">jinja2.Environment.</tt><tt class="descname">install_gettext_translations</tt><big>(</big><em>translations</em>, <em>newstyle=False</em><big>)</big><a class="headerlink" href="#jinja2.Environment.install_gettext_translations" title="Permalink to this definition"></a></dt>
<dd><p>Installs a translation globally for that environment.  The translations
object provided must implement at least <cite>ugettext</cite> and <cite>ungettext</cite>.
The <cite>gettext.NullTranslations</cite> and <cite>gettext.GNUTranslations</cite> classes
as well as <a class="reference external" href="http://babel.edgewall.org/">Babel</a>s <cite>Translations</cite> class are supported.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 2.5: </span>newstyle gettext added</p>
</div>
</dd></dl>

<dl class="method">
<dt id="jinja2.Environment.install_null_translations">
<tt class="descclassname">jinja2.Environment.</tt><tt class="descname">install_null_translations</tt><big>(</big><em>newstyle=False</em><big>)</big><a class="headerlink" href="#jinja2.Environment.install_null_translations" title="Permalink to this definition"></a></dt>
<dd><p>Install dummy gettext functions.  This is useful if you want to prepare
the application for internationalization but don&#8217;t want to implement the
full internationalization system yet.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 2.5: </span>newstyle gettext added</p>
</div>
</dd></dl>

<dl class="method">
<dt id="jinja2.Environment.install_gettext_callables">
<tt class="descclassname">jinja2.Environment.</tt><tt class="descname">install_gettext_callables</tt><big>(</big><em>gettext</em>, <em>ngettext</em>, <em>newstyle=False</em><big>)</big><a class="headerlink" href="#jinja2.Environment.install_gettext_callables" title="Permalink to this definition"></a></dt>
<dd><p>Installs the given <cite>gettext</cite> and <cite>ngettext</cite> callables into the
environment as globals.  They are supposed to behave exactly like the
standard library&#8217;s <tt class="xref py py-func docutils literal"><span class="pre">gettext.ugettext()</span></tt> and
<tt class="xref py py-func docutils literal"><span class="pre">gettext.ungettext()</span></tt> functions.</p>
<p>If <cite>newstyle</cite> is activated, the callables are wrapped to work like
newstyle callables.  See <a class="reference internal" href="#newstyle-gettext"><em>Newstyle Gettext</em></a> for more information.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.5.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="jinja2.Environment.uninstall_gettext_translations">
<tt class="descclassname">jinja2.Environment.</tt><tt class="descname">uninstall_gettext_translations</tt><big>(</big><big>)</big><a class="headerlink" href="#jinja2.Environment.uninstall_gettext_translations" title="Permalink to this definition"></a></dt>
<dd><p>Uninstall the translations again.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.Environment.extract_translations">
<tt class="descclassname">jinja2.Environment.</tt><tt class="descname">extract_translations</tt><big>(</big><em>source</em><big>)</big><a class="headerlink" href="#jinja2.Environment.extract_translations" title="Permalink to this definition"></a></dt>
<dd><p>Extract localizable strings from the given template node or source.</p>
<p>For every string found this function yields a <tt class="docutils literal"><span class="pre">(lineno,</span> <span class="pre">function,</span>
<span class="pre">message)</span></tt> tuple, where:</p>
<ul class="simple">
<li><cite>lineno</cite> is the number of the line on which the string was found,</li>
<li><cite>function</cite> is the name of the <cite>gettext</cite> function used (if the
string was extracted from embedded Python code), and</li>
<li><cite>message</cite> is the string itself (a <cite>unicode</cite> object, or a tuple
of <cite>unicode</cite> objects for functions with multiple string arguments).</li>
</ul>
<p>If <a class="reference external" href="http://babel.edgewall.org/">Babel</a> is installed, <a class="reference internal" href="integration.html#babel-integration"><em>the babel integration</em></a>
can be used to extract strings for babel.</p>
</dd></dl>

<p>For a web application that is available in multiple languages but gives all
the users the same language (for example a multilingual forum software
installed for a French community) may load the translations once and add the
translation methods to the environment at environment generation time:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">translations</span> <span class="o">=</span> <span class="n">get_gettext_translations</span><span class="p">()</span>
<span class="n">env</span> <span class="o">=</span> <span class="n">Environment</span><span class="p">(</span><span class="n">extensions</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;jinja2.ext.i18n&#39;</span><span class="p">])</span>
<span class="n">env</span><span class="o">.</span><span class="n">install_gettext_translations</span><span class="p">(</span><span class="n">translations</span><span class="p">)</span>
</pre></div>
</div>
<p>The <cite>get_gettext_translations</cite> function would return the translator for the
current configuration.  (For example by using <cite>gettext.find</cite>)</p>
<p>The usage of the <cite>i18n</cite> extension for template designers is covered as part
<a class="reference internal" href="templates.html#i18n-in-templates"><em>of the template documentation</em></a>.</p>
</div>
<div class="section" id="newstyle-gettext">
<span id="id2"></span><h3>Newstyle Gettext<a class="headerlink" href="#newstyle-gettext" title="Permalink to this headline"></a></h3>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.5.</span></p>
</div>
<p>Starting with version 2.5 you can use newstyle gettext calls.  These are
inspired by trac&#8217;s internal gettext functions and are fully supported by
the babel extraction tool.  They might not work as expected by other
extraction tools in case you are not using Babel&#8217;s.</p>
<p>What&#8217;s the big difference between standard and newstyle gettext calls?  In
general they are less to type and less error prone.  Also if they are used
in an autoescaping environment they better support automatic escaping.
Here are some common differences between old and new calls:</p>
<p>standard gettext:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">gettext</span><span class="o">(</span><span class="s1">&#39;Hello World!&#39;</span><span class="o">)</span> <span class="cp">}}</span>
<span class="cp">{{</span> <span class="nv">gettext</span><span class="o">(</span><span class="s1">&#39;Hello %(name)s!&#39;</span><span class="o">)|</span><span class="nf">format</span><span class="o">(</span><span class="nv">name</span><span class="o">=</span><span class="s1">&#39;World&#39;</span><span class="o">)</span> <span class="cp">}}</span>
<span class="cp">{{</span> <span class="nv">ngettext</span><span class="o">(</span><span class="s1">&#39;%(num)d apple&#39;</span><span class="o">,</span> <span class="s1">&#39;%(num)d apples&#39;</span><span class="o">,</span> <span class="nv">apples</span><span class="o">|</span><span class="nf">count</span><span class="o">)|</span><span class="nf">format</span><span class="o">(</span>
    <span class="nv">num</span><span class="o">=</span><span class="nv">apples</span><span class="o">|</span><span class="nf">count</span>
<span class="o">)</span><span class="cp">}}</span>
</pre></div>
</div>
<p>newstyle gettext looks like this instead:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">gettext</span><span class="o">(</span><span class="s1">&#39;Hello World!&#39;</span><span class="o">)</span> <span class="cp">}}</span>
<span class="cp">{{</span> <span class="nv">gettext</span><span class="o">(</span><span class="s1">&#39;Hello %(name)s!&#39;</span><span class="o">,</span> <span class="nv">name</span><span class="o">=</span><span class="s1">&#39;World&#39;</span><span class="o">)</span> <span class="cp">}}</span>
<span class="cp">{{</span> <span class="nv">ngettext</span><span class="o">(</span><span class="s1">&#39;%(num)d apple&#39;</span><span class="o">,</span> <span class="s1">&#39;%(num)d apples&#39;</span><span class="o">,</span> <span class="nv">apples</span><span class="o">|</span><span class="nf">count</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>
</div>
<p>The advantages of newstyle gettext are that you have less to type and that
named placeholders become mandatory.  The latter sounds like a
disadvantage but solves a lot of troubles translators are often facing
when they are unable to switch the positions of two placeholder.  With
newstyle gettext, all format strings look the same.</p>
<p>Furthermore with newstyle gettext, string formatting is also used if no
placeholders are used which makes all strings behave exactly the same.
Last but not least are newstyle gettext calls able to properly mark
strings for autoescaping which solves lots of escaping related issues many
templates are experiencing over time when using autoescaping.</p>
</div>
</div>
<div class="section" id="expression-statement">
<h2>Expression Statement<a class="headerlink" href="#expression-statement" title="Permalink to this headline"></a></h2>
<p><strong>Import name:</strong> <cite>jinja2.ext.do</cite></p>
<p>The &#8220;do&#8221; aka expression-statement extension adds a simple <cite>do</cite> tag to the
template engine that works like a variable expression but ignores the
return value.</p>
</div>
<div class="section" id="loop-controls">
<span id="loopcontrols-extension"></span><h2>Loop Controls<a class="headerlink" href="#loop-controls" title="Permalink to this headline"></a></h2>
<p><strong>Import name:</strong> <cite>jinja2.ext.loopcontrols</cite></p>
<p>This extension adds support for <cite>break</cite> and <cite>continue</cite> in loops.  After
enabling, Jinja2 provides those two keywords which work exactly like in
Python.</p>
</div>
<div class="section" id="with-statement">
<span id="with-extension"></span><h2>With Statement<a class="headerlink" href="#with-statement" title="Permalink to this headline"></a></h2>
<p><strong>Import name:</strong> <cite>jinja2.ext.with_</cite></p>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.3.</span></p>
</div>
<p>This extension adds support for the with keyword.  Using this keyword it
is possible to enforce a nested scope in a template.  Variables can be
declared directly in the opening block of the with statement or using a
standard <cite>set</cite> statement directly within.</p>
</div>
<div class="section" id="autoescape-extension">
<span id="id3"></span><h2>Autoescape Extension<a class="headerlink" href="#autoescape-extension" title="Permalink to this headline"></a></h2>
<p><strong>Import name:</strong> <cite>jinja2.ext.autoescape</cite></p>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.4.</span></p>
</div>
<p>The autoescape extension allows you to toggle the autoescape feature from
within the template.  If the environment&#8217;s <tt class="xref py py-attr docutils literal"><span class="pre">autoescape</span></tt>
setting is set to <cite>False</cite> it can be activated, if it&#8217;s <cite>True</cite> it can be
deactivated.  The setting overriding is scoped.</p>
</div>
<div class="section" id="module-jinja2.ext">
<span id="id4"></span><span id="writing-extensions"></span><h2>Writing Extensions<a class="headerlink" href="#module-jinja2.ext" title="Permalink to this headline"></a></h2>
<p>By writing extensions you can add custom tags to Jinja2.  This is a non-trivial
task and usually not needed as the default tags and expressions cover all
common use cases.  The i18n extension is a good example of why extensions are
useful. Another one would be fragment caching.</p>
<p>When writing extensions you have to keep in mind that you are working with the
Jinja2 template compiler which does not validate the node tree you are passing
to it.  If the AST is malformed you will get all kinds of compiler or runtime
errors that are horrible to debug.  Always make sure you are using the nodes
you create correctly.  The API documentation below shows which nodes exist and
how to use them.</p>
<div class="section" id="example-extension">
<h3>Example Extension<a class="headerlink" href="#example-extension" title="Permalink to this headline"></a></h3>
<p>The following example implements a <cite>cache</cite> tag for Jinja2 by using the
<a class="reference external" href="http://werkzeug.pocoo.org/">Werkzeug</a> caching contrib module:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">jinja2</span> <span class="kn">import</span> <span class="n">nodes</span>
<span class="kn">from</span> <span class="nn">jinja2.ext</span> <span class="kn">import</span> <span class="n">Extension</span>


<span class="k">class</span> <span class="nc">FragmentCacheExtension</span><span class="p">(</span><span class="n">Extension</span><span class="p">):</span>
    <span class="c"># a set of names that trigger the extension.</span>
    <span class="n">tags</span> <span class="o">=</span> <span class="nb">set</span><span class="p">([</span><span class="s">&#39;cache&#39;</span><span class="p">])</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">environment</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">FragmentCacheExtension</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="n">environment</span><span class="p">)</span>

        <span class="c"># add the defaults to the environment</span>
        <span class="n">environment</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span>
            <span class="n">fragment_cache_prefix</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">,</span>
            <span class="n">fragment_cache</span><span class="o">=</span><span class="bp">None</span>
        <span class="p">)</span>

    <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parser</span><span class="p">):</span>
        <span class="c"># the first token is the token that started the tag.  In our case</span>
        <span class="c"># we only listen to ``&#39;cache&#39;`` so this will be a name token with</span>
        <span class="c"># `cache` as value.  We get the line number so that we can give</span>
        <span class="c"># that line number to the nodes we create by hand.</span>
        <span class="n">lineno</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">stream</span><span class="p">)</span><span class="o">.</span><span class="n">lineno</span>

        <span class="c"># now we parse a single expression that is used as cache key.</span>
        <span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">parser</span><span class="o">.</span><span class="n">parse_expression</span><span class="p">()]</span>

        <span class="c"># if there is a comma, the user provided a timeout.  If not use</span>
        <span class="c"># None as second parameter.</span>
        <span class="k">if</span> <span class="n">parser</span><span class="o">.</span><span class="n">stream</span><span class="o">.</span><span class="n">skip_if</span><span class="p">(</span><span class="s">&#39;comma&#39;</span><span class="p">):</span>
            <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">parse_expression</span><span class="p">())</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">nodes</span><span class="o">.</span><span class="n">Const</span><span class="p">(</span><span class="bp">None</span><span class="p">))</span>

        <span class="c"># now we parse the body of the cache block up to `endcache` and</span>
        <span class="c"># drop the needle (which would always be `endcache` in that case)</span>
        <span class="n">body</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_statements</span><span class="p">([</span><span class="s">&#39;name:endcache&#39;</span><span class="p">],</span> <span class="n">drop_needle</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>

        <span class="c"># now return a `CallBlock` node that calls our _cache_support</span>
        <span class="c"># helper method on this extension.</span>
        <span class="k">return</span> <span class="n">nodes</span><span class="o">.</span><span class="n">CallBlock</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">call_method</span><span class="p">(</span><span class="s">&#39;_cache_support&#39;</span><span class="p">,</span> <span class="n">args</span><span class="p">),</span>
                               <span class="p">[],</span> <span class="p">[],</span> <span class="n">body</span><span class="p">)</span><span class="o">.</span><span class="n">set_lineno</span><span class="p">(</span><span class="n">lineno</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_cache_support</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="n">caller</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Helper callback.&quot;&quot;&quot;</span>
        <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">environment</span><span class="o">.</span><span class="n">fragment_cache_prefix</span> <span class="o">+</span> <span class="n">name</span>

        <span class="c"># try to load the block from the cache</span>
        <span class="c"># if there is no fragment in the cache, render it and store</span>
        <span class="c"># it in the cache.</span>
        <span class="n">rv</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">environment</span><span class="o">.</span><span class="n">fragment_cache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">rv</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">rv</span>
        <span class="n">rv</span> <span class="o">=</span> <span class="n">caller</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">environment</span><span class="o">.</span><span class="n">fragment_cache</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">rv</span><span class="p">,</span> <span class="n">timeout</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">rv</span>
</pre></div>
</div>
<p>And here is how you use it in an environment:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">jinja2</span> <span class="kn">import</span> <span class="n">Environment</span>
<span class="kn">from</span> <span class="nn">werkzeug.contrib.cache</span> <span class="kn">import</span> <span class="n">SimpleCache</span>

<span class="n">env</span> <span class="o">=</span> <span class="n">Environment</span><span class="p">(</span><span class="n">extensions</span><span class="o">=</span><span class="p">[</span><span class="n">FragmentCacheExtension</span><span class="p">])</span>
<span class="n">env</span><span class="o">.</span><span class="n">fragment_cache</span> <span class="o">=</span> <span class="n">SimpleCache</span><span class="p">()</span>
</pre></div>
</div>
<p>Inside the template it&#8217;s then possible to mark blocks as cacheable.  The
following example caches a sidebar for 300 seconds:</p>
<div class="highlight-html+jinja"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">cache</span> <span class="s1">&#39;sidebar&#39;</span><span class="o">,</span> <span class="m">300</span> <span class="cp">%}</span>
<span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;sidebar&quot;</span><span class="nt">&gt;</span>
    ...
<span class="nt">&lt;/div&gt;</span>
<span class="cp">{%</span> <span class="k">endcache</span> <span class="cp">%}</span>
</pre></div>
</div>
</div>
<div class="section" id="extension-api">
<h3>Extension API<a class="headerlink" href="#extension-api" title="Permalink to this headline"></a></h3>
<p>Extensions always have to extend the <a class="reference internal" href="#jinja2.ext.Extension" title="jinja2.ext.Extension"><tt class="xref py py-class docutils literal"><span class="pre">jinja2.ext.Extension</span></tt></a> class:</p>
<dl class="class">
<dt id="jinja2.ext.Extension">
<em class="property">class </em><tt class="descclassname">jinja2.ext.</tt><tt class="descname">Extension</tt><big>(</big><em>environment</em><big>)</big><a class="headerlink" href="#jinja2.ext.Extension" title="Permalink to this definition"></a></dt>
<dd><p>Extensions can be used to add extra functionality to the Jinja template
system at the parser level.  Custom extensions are bound to an environment
but may not store environment specific data on <cite>self</cite>.  The reason for
this is that an extension can be bound to another environment (for
overlays) by creating a copy and reassigning the <cite>environment</cite> attribute.</p>
<p>As extensions are created by the environment they cannot accept any
arguments for configuration.  One may want to work around that by using
a factory function, but that is not possible as extensions are identified
by their import name.  The correct way to configure the extension is
storing the configuration values on the environment.  Because this way the
environment ends up acting as central configuration storage the
attributes may clash which is why extensions have to ensure that the names
they choose for configuration are not too generic.  <tt class="docutils literal"><span class="pre">prefix</span></tt> for example
is a terrible name, <tt class="docutils literal"><span class="pre">fragment_cache_prefix</span></tt> on the other hand is a good
name as includes the name of the extension (fragment cache).</p>
<dl class="attribute">
<dt id="jinja2.ext.Extension.identifier">
<tt class="descname">identifier</tt><a class="headerlink" href="#jinja2.ext.Extension.identifier" title="Permalink to this definition"></a></dt>
<dd><p>The identifier of the extension.  This is always the true import name
of the extension class and must not be changed.</p>
</dd></dl>

<dl class="attribute">
<dt id="jinja2.ext.Extension.tags">
<tt class="descname">tags</tt><a class="headerlink" href="#jinja2.ext.Extension.tags" title="Permalink to this definition"></a></dt>
<dd><p>If the extension implements custom tags this is a set of tag names
the extension is listening for.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.ext.Extension.attr">
<tt class="descname">attr</tt><big>(</big><em>name</em>, <em>lineno=None</em><big>)</big><a class="headerlink" href="#jinja2.ext.Extension.attr" title="Permalink to this definition"></a></dt>
<dd><p>Return an attribute node for the current extension.  This is useful
to pass constants on extensions to generated template code.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="bp">self</span><span class="o">.</span><span class="n">attr</span><span class="p">(</span><span class="s">&#39;_my_attribute&#39;</span><span class="p">,</span> <span class="n">lineno</span><span class="o">=</span><span class="n">lineno</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="jinja2.ext.Extension.call_method">
<tt class="descname">call_method</tt><big>(</big><em>name</em>, <em>args=None</em>, <em>kwargs=None</em>, <em>dyn_args=None</em>, <em>dyn_kwargs=None</em>, <em>lineno=None</em><big>)</big><a class="headerlink" href="#jinja2.ext.Extension.call_method" title="Permalink to this definition"></a></dt>
<dd><p>Call a method of the extension.  This is a shortcut for
<a class="reference internal" href="templates.html#attr" title="attr"><tt class="xref py py-meth docutils literal"><span class="pre">attr()</span></tt></a> + <a class="reference internal" href="#jinja2.nodes.Call" title="jinja2.nodes.Call"><tt class="xref py py-class docutils literal"><span class="pre">jinja2.nodes.Call</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.ext.Extension.filter_stream">
<tt class="descname">filter_stream</tt><big>(</big><em>stream</em><big>)</big><a class="headerlink" href="#jinja2.ext.Extension.filter_stream" title="Permalink to this definition"></a></dt>
<dd><p>It&#8217;s passed a <a class="reference internal" href="#jinja2.lexer.TokenStream" title="jinja2.lexer.TokenStream"><tt class="xref py py-class docutils literal"><span class="pre">TokenStream</span></tt></a> that can be used
to filter tokens returned.  This method has to return an iterable of
<a class="reference internal" href="#jinja2.lexer.Token" title="jinja2.lexer.Token"><tt class="xref py py-class docutils literal"><span class="pre">Token</span></tt></a>s, but it doesn&#8217;t have to return a
<a class="reference internal" href="#jinja2.lexer.TokenStream" title="jinja2.lexer.TokenStream"><tt class="xref py py-class docutils literal"><span class="pre">TokenStream</span></tt></a>.</p>
<p>In the <cite>ext</cite> folder of the Jinja2 source distribution there is a file
called <cite>inlinegettext.py</cite> which implements a filter that utilizes this
method.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.ext.Extension.parse">
<tt class="descname">parse</tt><big>(</big><em>parser</em><big>)</big><a class="headerlink" href="#jinja2.ext.Extension.parse" title="Permalink to this definition"></a></dt>
<dd><p>If any of the <a class="reference internal" href="#jinja2.ext.Extension.tags" title="jinja2.ext.Extension.tags"><tt class="xref py py-attr docutils literal"><span class="pre">tags</span></tt></a> matched this method is called with the
parser as first argument.  The token the parser stream is pointing at
is the name token that matched.  This method has to return one or a
list of multiple nodes.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.ext.Extension.preprocess">
<tt class="descname">preprocess</tt><big>(</big><em>source</em>, <em>name</em>, <em>filename=None</em><big>)</big><a class="headerlink" href="#jinja2.ext.Extension.preprocess" title="Permalink to this definition"></a></dt>
<dd><p>This method is called before the actual lexing and can be used to
preprocess the source.  The <cite>filename</cite> is optional.  The return value
must be the preprocessed source.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="parser-api">
<h3>Parser API<a class="headerlink" href="#parser-api" title="Permalink to this headline"></a></h3>
<p>The parser passed to <a class="reference internal" href="#jinja2.ext.Extension.parse" title="jinja2.ext.Extension.parse"><tt class="xref py py-meth docutils literal"><span class="pre">Extension.parse()</span></tt></a> provides ways to parse
expressions of different types.  The following methods may be used by
extensions:</p>
<dl class="class">
<dt id="jinja2.parser.Parser">
<em class="property">class </em><tt class="descclassname">jinja2.parser.</tt><tt class="descname">Parser</tt><big>(</big><em>environment</em>, <em>source</em>, <em>name=None</em>, <em>filename=None</em>, <em>state=None</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser" title="Permalink to this definition"></a></dt>
<dd><p>This is the central parsing class Jinja2 uses.  It&#8217;s passed to
extensions and can be used to parse expressions or statements.</p>
<dl class="attribute">
<dt id="jinja2.ext.Parser.filename">
<tt class="descname">filename</tt><a class="headerlink" href="#jinja2.ext.Parser.filename" title="Permalink to this definition"></a></dt>
<dd><p>The filename of the template the parser processes.  This is <strong>not</strong>
the load name of the template.  For the load name see <a class="reference internal" href="#jinja2.ext.Parser.name" title="jinja2.ext.Parser.name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a>.
For templates that were not loaded form the file system this is
<cite>None</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="jinja2.ext.Parser.name">
<tt class="descname">name</tt><a class="headerlink" href="#jinja2.ext.Parser.name" title="Permalink to this definition"></a></dt>
<dd><p>The load name of the template.</p>
</dd></dl>

<dl class="attribute">
<dt id="jinja2.ext.Parser.stream">
<tt class="descname">stream</tt><a class="headerlink" href="#jinja2.ext.Parser.stream" title="Permalink to this definition"></a></dt>
<dd><p>The current <a class="reference internal" href="#jinja2.lexer.TokenStream" title="jinja2.lexer.TokenStream"><tt class="xref py py-class docutils literal"><span class="pre">TokenStream</span></tt></a></p>
</dd></dl>

<dl class="method">
<dt id="jinja2.parser.Parser.fail">
<tt class="descname">fail</tt><big>(</big><em>msg</em>, <em>lineno=None</em>, <em>exc=&lt;class 'jinja2.exceptions.TemplateSyntaxError'&gt;</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser.fail" title="Permalink to this definition"></a></dt>
<dd><p>Convenience method that raises <cite>exc</cite> with the message, passed
line number or last line number as well as the current name and
filename.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.parser.Parser.free_identifier">
<tt class="descname">free_identifier</tt><big>(</big><em>lineno=None</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser.free_identifier" title="Permalink to this definition"></a></dt>
<dd><p>Return a new free identifier as <a class="reference internal" href="#jinja2.nodes.InternalName" title="jinja2.nodes.InternalName"><tt class="xref py py-class docutils literal"><span class="pre">InternalName</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.parser.Parser.parse_assign_target">
<tt class="descname">parse_assign_target</tt><big>(</big><em>with_tuple=True</em>, <em>name_only=False</em>, <em>extra_end_rules=None</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser.parse_assign_target" title="Permalink to this definition"></a></dt>
<dd><p>Parse an assignment target.  As Jinja2 allows assignments to
tuples, this function can parse all allowed assignment targets.  Per
default assignments to tuples are parsed, that can be disable however
by setting <cite>with_tuple</cite> to <cite>False</cite>.  If only assignments to names are
wanted <cite>name_only</cite> can be set to <cite>True</cite>.  The <cite>extra_end_rules</cite>
parameter is forwarded to the tuple parsing function.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.parser.Parser.parse_expression">
<tt class="descname">parse_expression</tt><big>(</big><em>with_condexpr=True</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser.parse_expression" title="Permalink to this definition"></a></dt>
<dd><p>Parse an expression.  Per default all expressions are parsed, if
the optional <cite>with_condexpr</cite> parameter is set to <cite>False</cite> conditional
expressions are not parsed.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.parser.Parser.parse_statements">
<tt class="descname">parse_statements</tt><big>(</big><em>end_tokens</em>, <em>drop_needle=False</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser.parse_statements" title="Permalink to this definition"></a></dt>
<dd><p>Parse multiple statements into a list until one of the end tokens
is reached.  This is used to parse the body of statements as it also
parses template data if appropriate.  The parser checks first if the
current token is a colon and skips it if there is one.  Then it checks
for the block end and parses until if one of the <cite>end_tokens</cite> is
reached.  Per default the active token in the stream at the end of
the call is the matched end token.  If this is not wanted <cite>drop_needle</cite>
can be set to <cite>True</cite> and the end token is removed.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.parser.Parser.parse_tuple">
<tt class="descname">parse_tuple</tt><big>(</big><em>simplified=False</em>, <em>with_condexpr=True</em>, <em>extra_end_rules=None</em>, <em>explicit_parentheses=False</em><big>)</big><a class="headerlink" href="#jinja2.parser.Parser.parse_tuple" title="Permalink to this definition"></a></dt>
<dd><p>Works like <cite>parse_expression</cite> but if multiple expressions are
delimited by a comma a <a class="reference internal" href="#jinja2.nodes.Tuple" title="jinja2.nodes.Tuple"><tt class="xref py py-class docutils literal"><span class="pre">Tuple</span></tt></a> node is created.
This method could also return a regular expression instead of a tuple
if no commas where found.</p>
<p>The default parsing mode is a full tuple.  If <cite>simplified</cite> is <cite>True</cite>
only names and literals are parsed.  The <cite>no_condexpr</cite> parameter is
forwarded to <tt class="xref py py-meth docutils literal"><span class="pre">parse_expression()</span></tt>.</p>
<p>Because tuples do not require delimiters and may end in a bogus comma
an extra hint is needed that marks the end of a tuple.  For example
for loops support tuples between <cite>for</cite> and <cite>in</cite>.  In that case the
<cite>extra_end_rules</cite> is set to <tt class="docutils literal"><span class="pre">['name:in']</span></tt>.</p>
<p><cite>explicit_parentheses</cite> is true if the parsing was triggered by an
expression in parentheses.  This is used to figure out if an empty
tuple is a valid expression or not.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="jinja2.lexer.TokenStream">
<em class="property">class </em><tt class="descclassname">jinja2.lexer.</tt><tt class="descname">TokenStream</tt><big>(</big><em>generator</em>, <em>name</em>, <em>filename</em><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream" title="Permalink to this definition"></a></dt>
<dd><p>A token stream is an iterable that yields <tt class="xref py py-class docutils literal"><span class="pre">Token</span></tt>s.  The
parser however does not iterate over it but calls <tt class="xref py py-meth docutils literal"><span class="pre">next()</span></tt> to go
one token ahead.  The current active token is stored as <a class="reference internal" href="#jinja2.ext.TokenStream.current" title="jinja2.ext.TokenStream.current"><tt class="xref py py-attr docutils literal"><span class="pre">current</span></tt></a>.</p>
<dl class="attribute">
<dt id="jinja2.ext.TokenStream.current">
<tt class="descname">current</tt><a class="headerlink" href="#jinja2.ext.TokenStream.current" title="Permalink to this definition"></a></dt>
<dd><p>The current <a class="reference internal" href="#jinja2.lexer.Token" title="jinja2.lexer.Token"><tt class="xref py py-class docutils literal"><span class="pre">Token</span></tt></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="jinja2.lexer.TokenStream.eos">
<tt class="descname">eos</tt><a class="headerlink" href="#jinja2.lexer.TokenStream.eos" title="Permalink to this definition"></a></dt>
<dd><p>Are we at the end of the stream?</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.expect">
<tt class="descname">expect</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.expect" title="Permalink to this definition"></a></dt>
<dd><p>Expect a given token type and return it.  This accepts the same
argument as <a class="reference internal" href="#jinja2.lexer.Token.test" title="jinja2.lexer.Token.test"><tt class="xref py py-meth docutils literal"><span class="pre">jinja2.lexer.Token.test()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.look">
<tt class="descname">look</tt><big>(</big><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.look" title="Permalink to this definition"></a></dt>
<dd><p>Look at the next token.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.next">
<tt class="descname">next</tt><big>(</big><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.next" title="Permalink to this definition"></a></dt>
<dd><p>Go one token ahead and return the old one</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.next_if">
<tt class="descname">next_if</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.next_if" title="Permalink to this definition"></a></dt>
<dd><p>Perform the token test and return the token if it matched.
Otherwise the return value is <cite>None</cite>.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.push">
<tt class="descname">push</tt><big>(</big><em>token</em><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.push" title="Permalink to this definition"></a></dt>
<dd><p>Push a token back to the stream.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.skip">
<tt class="descname">skip</tt><big>(</big><em>n=1</em><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.skip" title="Permalink to this definition"></a></dt>
<dd><p>Got n tokens ahead.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.TokenStream.skip_if">
<tt class="descname">skip_if</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#jinja2.lexer.TokenStream.skip_if" title="Permalink to this definition"></a></dt>
<dd><p>Like <tt class="xref py py-meth docutils literal"><span class="pre">next_if()</span></tt> but only returns <cite>True</cite> or <cite>False</cite>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="jinja2.lexer.Token">
<em class="property">class </em><tt class="descclassname">jinja2.lexer.</tt><tt class="descname">Token</tt><a class="headerlink" href="#jinja2.lexer.Token" title="Permalink to this definition"></a></dt>
<dd><p>Token class.</p>
<dl class="attribute">
<dt id="jinja2.ext.Token.lineno">
<tt class="descname">lineno</tt><a class="headerlink" href="#jinja2.ext.Token.lineno" title="Permalink to this definition"></a></dt>
<dd><p>The line number of the token</p>
</dd></dl>

<dl class="attribute">
<dt id="jinja2.ext.Token.type">
<tt class="descname">type</tt><a class="headerlink" href="#jinja2.ext.Token.type" title="Permalink to this definition"></a></dt>
<dd><p>The type of the token.  This string is interned so you may compare
it with arbitrary strings using the <cite>is</cite> operator.</p>
</dd></dl>

<dl class="attribute">
<dt id="jinja2.ext.Token.value">
<tt class="descname">value</tt><a class="headerlink" href="#jinja2.ext.Token.value" title="Permalink to this definition"></a></dt>
<dd><p>The value of the token.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.Token.test">
<tt class="descname">test</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#jinja2.lexer.Token.test" title="Permalink to this definition"></a></dt>
<dd><p>Test a token against a token expression.  This can either be a
token type or <tt class="docutils literal"><span class="pre">'token_type:token_value'</span></tt>.  This can only test
against string values and types.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.lexer.Token.test_any">
<tt class="descname">test_any</tt><big>(</big><em>*iterable</em><big>)</big><a class="headerlink" href="#jinja2.lexer.Token.test_any" title="Permalink to this definition"></a></dt>
<dd><p>Test against multiple token expressions.</p>
</dd></dl>

</dd></dl>

<p>There is also a utility function in the lexer module that can count newline
characters in strings:</p>
<dl class="function">
<dt id="jinja2.lexer.count_newlines">
<tt class="descclassname">jinja2.lexer.</tt><tt class="descname">count_newlines</tt><big>(</big><em>value</em><big>)</big><a class="headerlink" href="#jinja2.lexer.count_newlines" title="Permalink to this definition"></a></dt>
<dd><p>Count the number of newline characters in the string.  This is
useful for extensions that filter a stream.</p>
</dd></dl>

</div>
<div class="section" id="ast">
<h3>AST<a class="headerlink" href="#ast" title="Permalink to this headline"></a></h3>
<p>The AST (Abstract Syntax Tree) is used to represent a template after parsing.
It&#8217;s build of nodes that the compiler then converts into executable Python
code objects.  Extensions that provide custom statements can return nodes to
execute custom Python code.</p>
<p>The list below describes all nodes that are currently available.  The AST may
change between Jinja2 versions but will stay backwards compatible.</p>
<p>For more information have a look at the repr of <a class="reference internal" href="api.html#jinja2.Environment.parse" title="jinja2.Environment.parse"><tt class="xref py py-meth docutils literal"><span class="pre">jinja2.Environment.parse()</span></tt></a>.</p>
<span class="target" id="module-jinja2.nodes"></span><dl class="class">
<dt id="jinja2.nodes.Node">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Node</tt><a class="headerlink" href="#jinja2.nodes.Node" title="Permalink to this definition"></a></dt>
<dd><p>Baseclass for all Jinja2 nodes.  There are a number of nodes available
of different types.  There are four major types:</p>
<ul class="simple">
<li><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a>: statements</li>
<li><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a>: expressions</li>
<li><a class="reference internal" href="#jinja2.nodes.Helper" title="jinja2.nodes.Helper"><tt class="xref py py-class docutils literal"><span class="pre">Helper</span></tt></a>: helper nodes</li>
<li><a class="reference internal" href="#jinja2.nodes.Template" title="jinja2.nodes.Template"><tt class="xref py py-class docutils literal"><span class="pre">Template</span></tt></a>: the outermost wrapper node</li>
</ul>
<p>All nodes have fields and attributes.  Fields may be other nodes, lists,
or arbitrary values.  Fields are passed to the constructor as regular
positional arguments, attributes as keyword arguments.  Each node has
two attributes: <cite>lineno</cite> (the line number of the node) and <cite>environment</cite>.
The <cite>environment</cite> attribute is set at the end of the parsing process for
all nodes automatically.</p>
<dl class="method">
<dt id="jinja2.nodes.Node.find">
<tt class="descname">find</tt><big>(</big><em>node_type</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.find" title="Permalink to this definition"></a></dt>
<dd><p>Find the first node of a given type.  If no such node exists the
return value is <cite>None</cite>.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Node.find_all">
<tt class="descname">find_all</tt><big>(</big><em>node_type</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.find_all" title="Permalink to this definition"></a></dt>
<dd><p>Find all the nodes of a given type.  If the type is a tuple,
the check is performed for any of the tuple items.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Node.iter_child_nodes">
<tt class="descname">iter_child_nodes</tt><big>(</big><em>exclude=None</em>, <em>only=None</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.iter_child_nodes" title="Permalink to this definition"></a></dt>
<dd><p>Iterates over all direct child nodes of the node.  This iterates
over all fields and yields the values of they are nodes.  If the value
of a field is a list all the nodes in that list are returned.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Node.iter_fields">
<tt class="descname">iter_fields</tt><big>(</big><em>exclude=None</em>, <em>only=None</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.iter_fields" title="Permalink to this definition"></a></dt>
<dd><p>This method iterates over all fields that are defined and yields
<tt class="docutils literal"><span class="pre">(key,</span> <span class="pre">value)</span></tt> tuples.  Per default all fields are returned, but
it&#8217;s possible to limit that to some fields by providing the <cite>only</cite>
parameter or to exclude some using the <cite>exclude</cite> parameter.  Both
should be sets or tuples of field names.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Node.set_ctx">
<tt class="descname">set_ctx</tt><big>(</big><em>ctx</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.set_ctx" title="Permalink to this definition"></a></dt>
<dd><p>Reset the context of a node and all child nodes.  Per default the
parser will all generate nodes that have a &#8216;load&#8217; context as it&#8217;s the
most common one.  This method is used in the parser to set assignment
targets and other nodes to a store context.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Node.set_environment">
<tt class="descname">set_environment</tt><big>(</big><em>environment</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.set_environment" title="Permalink to this definition"></a></dt>
<dd><p>Set the environment for all nodes.</p>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Node.set_lineno">
<tt class="descname">set_lineno</tt><big>(</big><em>lineno</em>, <em>override=False</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Node.set_lineno" title="Permalink to this definition"></a></dt>
<dd><p>Set the line numbers of the node and children.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Expr">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Expr</tt><a class="headerlink" href="#jinja2.nodes.Expr" title="Permalink to this definition"></a></dt>
<dd><p>Baseclass for all expressions.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Node" title="jinja2.nodes.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="jinja2.nodes.Expr.as_const">
<tt class="descname">as_const</tt><big>(</big><em>eval_ctx=None</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Expr.as_const" title="Permalink to this definition"></a></dt>
<dd><p>Return the value of the expression as constant or raise
<a class="reference internal" href="#jinja2.nodes.Impossible" title="jinja2.nodes.Impossible"><tt class="xref py py-exc docutils literal"><span class="pre">Impossible</span></tt></a> if this was not possible.</p>
<p>An <a class="reference internal" href="api.html#jinja2.nodes.EvalContext" title="jinja2.nodes.EvalContext"><tt class="xref py py-class docutils literal"><span class="pre">EvalContext</span></tt></a> can be provided, if none is given
a default context is created which requires the nodes to have
an attached environment.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 2.4: </span>the <cite>eval_ctx</cite> parameter was added.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="jinja2.nodes.Expr.can_assign">
<tt class="descname">can_assign</tt><big>(</big><big>)</big><a class="headerlink" href="#jinja2.nodes.Expr.can_assign" title="Permalink to this definition"></a></dt>
<dd><p>Check if it&#8217;s possible to assign something to this node.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.BinExpr">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">BinExpr</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.BinExpr" title="Permalink to this definition"></a></dt>
<dd><p>Baseclass for all binary expressions.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Add">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Add</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Add" title="Permalink to this definition"></a></dt>
<dd><p>Add the left to the right node.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.And">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">And</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.And" title="Permalink to this definition"></a></dt>
<dd><p>Short circuited AND.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Div">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Div</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Div" title="Permalink to this definition"></a></dt>
<dd><p>Divides the left by the right node.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.FloorDiv">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">FloorDiv</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.FloorDiv" title="Permalink to this definition"></a></dt>
<dd><p>Divides the left by the right node and truncates conver the
result into an integer by truncating.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Mod">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Mod</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Mod" title="Permalink to this definition"></a></dt>
<dd><p>Left modulo right.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Mul">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Mul</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Mul" title="Permalink to this definition"></a></dt>
<dd><p>Multiplies the left with the right node.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Or">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Or</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Or" title="Permalink to this definition"></a></dt>
<dd><p>Short circuited OR.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Pow">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Pow</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Pow" title="Permalink to this definition"></a></dt>
<dd><p>Left to the power of right.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Sub">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Sub</tt><big>(</big><em>left</em>, <em>right</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Sub" title="Permalink to this definition"></a></dt>
<dd><p>Subtract the right from the left node.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.BinExpr" title="jinja2.nodes.BinExpr"><tt class="xref py py-class docutils literal"><span class="pre">BinExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Call">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Call</tt><big>(</big><em>node</em>, <em>args</em>, <em>kwargs</em>, <em>dyn_args</em>, <em>dyn_kwargs</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Call" title="Permalink to this definition"></a></dt>
<dd><p>Calls an expression.  <cite>args</cite> is a list of arguments, <cite>kwargs</cite> a list
of keyword arguments (list of <a class="reference internal" href="#jinja2.nodes.Keyword" title="jinja2.nodes.Keyword"><tt class="xref py py-class docutils literal"><span class="pre">Keyword</span></tt></a> nodes), and <cite>dyn_args</cite>
and <cite>dyn_kwargs</cite> has to be either <cite>None</cite> or a node that is used as
node for dynamic positional (<tt class="docutils literal"><span class="pre">*args</span></tt>) or keyword (<tt class="docutils literal"><span class="pre">**kwargs</span></tt>)
arguments.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Compare">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Compare</tt><big>(</big><em>expr</em>, <em>ops</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Compare" title="Permalink to this definition"></a></dt>
<dd><p>Compares an expression with some other expressions.  <cite>ops</cite> must be a
list of <a class="reference internal" href="#jinja2.nodes.Operand" title="jinja2.nodes.Operand"><tt class="xref py py-class docutils literal"><span class="pre">Operand</span></tt></a>s.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Concat">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Concat</tt><big>(</big><em>nodes</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Concat" title="Permalink to this definition"></a></dt>
<dd><p>Concatenates the list of expressions provided after converting them to
unicode.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.CondExpr">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">CondExpr</tt><big>(</big><em>test</em>, <em>expr1</em>, <em>expr2</em><big>)</big><a class="headerlink" href="#jinja2.nodes.CondExpr" title="Permalink to this definition"></a></dt>
<dd><p>A conditional expression (inline if expression).  (<tt class="docutils literal"><span class="pre">{{</span>
<span class="pre">foo</span> <span class="pre">if</span> <span class="pre">bar</span> <span class="pre">else</span> <span class="pre">baz</span> <span class="pre">}}</span></tt>)</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.ContextReference">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">ContextReference</tt><a class="headerlink" href="#jinja2.nodes.ContextReference" title="Permalink to this definition"></a></dt>
<dd><p>Returns the current template context.  It can be used like a
<a class="reference internal" href="#jinja2.nodes.Name" title="jinja2.nodes.Name"><tt class="xref py py-class docutils literal"><span class="pre">Name</span></tt></a> node, with a <tt class="docutils literal"><span class="pre">'load'</span></tt> ctx and will return the
current <a class="reference internal" href="api.html#jinja2.runtime.Context" title="jinja2.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> object.</p>
<p>Here an example that assigns the current template name to a
variable named <cite>foo</cite>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Assign</span><span class="p">(</span><span class="n">Name</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="s">&#39;store&#39;</span><span class="p">),</span>
       <span class="n">Getattr</span><span class="p">(</span><span class="n">ContextReference</span><span class="p">(),</span> <span class="s">&#39;name&#39;</span><span class="p">))</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.EnvironmentAttribute">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">EnvironmentAttribute</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#jinja2.nodes.EnvironmentAttribute" title="Permalink to this definition"></a></dt>
<dd><p>Loads an attribute from the environment object.  This is useful for
extensions that want to call a callback stored on the environment.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.ExtensionAttribute">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">ExtensionAttribute</tt><big>(</big><em>identifier</em>, <em>name</em><big>)</big><a class="headerlink" href="#jinja2.nodes.ExtensionAttribute" title="Permalink to this definition"></a></dt>
<dd><p>Returns the attribute of an extension bound to the environment.
The identifier is the identifier of the <tt class="xref py py-class docutils literal"><span class="pre">Extension</span></tt>.</p>
<p>This node is usually constructed by calling the
<a class="reference internal" href="#jinja2.ext.Extension.attr" title="jinja2.ext.Extension.attr"><tt class="xref py py-meth docutils literal"><span class="pre">attr()</span></tt></a> method on an extension.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Filter">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Filter</tt><big>(</big><em>node</em>, <em>name</em>, <em>args</em>, <em>kwargs</em>, <em>dyn_args</em>, <em>dyn_kwargs</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Filter" title="Permalink to this definition"></a></dt>
<dd><p>This node applies a filter on an expression.  <cite>name</cite> is the name of
the filter, the rest of the fields are the same as for <a class="reference internal" href="#jinja2.nodes.Call" title="jinja2.nodes.Call"><tt class="xref py py-class docutils literal"><span class="pre">Call</span></tt></a>.</p>
<p>If the <cite>node</cite> of a filter is <cite>None</cite> the contents of the last buffer are
filtered.  Buffers are created by macros and filter blocks.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Getattr">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Getattr</tt><big>(</big><em>node</em>, <em>attr</em>, <em>ctx</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Getattr" title="Permalink to this definition"></a></dt>
<dd><p>Get an attribute or item from an expression that is a ascii-only
bytestring and prefer the attribute.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Getitem">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Getitem</tt><big>(</big><em>node</em>, <em>arg</em>, <em>ctx</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Getitem" title="Permalink to this definition"></a></dt>
<dd><p>Get an attribute or item from an expression and prefer the item.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.ImportedName">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">ImportedName</tt><big>(</big><em>importname</em><big>)</big><a class="headerlink" href="#jinja2.nodes.ImportedName" title="Permalink to this definition"></a></dt>
<dd><p>If created with an import name the import name is returned on node
access.  For example <tt class="docutils literal"><span class="pre">ImportedName('cgi.escape')</span></tt> returns the <cite>escape</cite>
function from the cgi module on evaluation.  Imports are optimized by the
compiler so there is no need to assign them to local variables.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.InternalName">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">InternalName</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#jinja2.nodes.InternalName" title="Permalink to this definition"></a></dt>
<dd><p>An internal name in the compiler.  You cannot create these nodes
yourself but the parser provides a
<a class="reference internal" href="#jinja2.parser.Parser.free_identifier" title="jinja2.parser.Parser.free_identifier"><tt class="xref py py-meth docutils literal"><span class="pre">free_identifier()</span></tt></a> method that creates
a new identifier for you.  This identifier is not available from the
template and is not threated specially by the compiler.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Literal">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Literal</tt><a class="headerlink" href="#jinja2.nodes.Literal" title="Permalink to this definition"></a></dt>
<dd><p>Baseclass for literals.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Const">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Const</tt><big>(</big><em>value</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Const" title="Permalink to this definition"></a></dt>
<dd><p>All constant values.  The parser will return this node for simple
constants such as <tt class="docutils literal"><span class="pre">42</span></tt> or <tt class="docutils literal"><span class="pre">&quot;foo&quot;</span></tt> but it can be used to store more
complex values such as lists too.  Only constants with a safe
representation (objects where <tt class="docutils literal"><span class="pre">eval(repr(x))</span> <span class="pre">==</span> <span class="pre">x</span></tt> is true).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Literal" title="jinja2.nodes.Literal"><tt class="xref py py-class docutils literal"><span class="pre">Literal</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Dict">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Dict</tt><big>(</big><em>items</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Dict" title="Permalink to this definition"></a></dt>
<dd><p>Any dict literal such as <tt class="docutils literal"><span class="pre">{1:</span> <span class="pre">2,</span> <span class="pre">3:</span> <span class="pre">4}</span></tt>.  The items must be a list of
<a class="reference internal" href="#jinja2.nodes.Pair" title="jinja2.nodes.Pair"><tt class="xref py py-class docutils literal"><span class="pre">Pair</span></tt></a> nodes.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Literal" title="jinja2.nodes.Literal"><tt class="xref py py-class docutils literal"><span class="pre">Literal</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.List">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">List</tt><big>(</big><em>items</em><big>)</big><a class="headerlink" href="#jinja2.nodes.List" title="Permalink to this definition"></a></dt>
<dd><p>Any list literal such as <tt class="docutils literal"><span class="pre">[1,</span> <span class="pre">2,</span> <span class="pre">3]</span></tt></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Literal" title="jinja2.nodes.Literal"><tt class="xref py py-class docutils literal"><span class="pre">Literal</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.TemplateData">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">TemplateData</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#jinja2.nodes.TemplateData" title="Permalink to this definition"></a></dt>
<dd><p>A constant template string.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Literal" title="jinja2.nodes.Literal"><tt class="xref py py-class docutils literal"><span class="pre">Literal</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Tuple">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Tuple</tt><big>(</big><em>items</em>, <em>ctx</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Tuple" title="Permalink to this definition"></a></dt>
<dd><p>For loop unpacking and some other things like multiple arguments
for subscripts.  Like for <a class="reference internal" href="#jinja2.nodes.Name" title="jinja2.nodes.Name"><tt class="xref py py-class docutils literal"><span class="pre">Name</span></tt></a> <cite>ctx</cite> specifies if the tuple
is used for loading the names or storing.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Literal" title="jinja2.nodes.Literal"><tt class="xref py py-class docutils literal"><span class="pre">Literal</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.MarkSafe">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">MarkSafe</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#jinja2.nodes.MarkSafe" title="Permalink to this definition"></a></dt>
<dd><p>Mark the wrapped expression as safe (wrap it as <cite>Markup</cite>).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.MarkSafeIfAutoescape">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">MarkSafeIfAutoescape</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#jinja2.nodes.MarkSafeIfAutoescape" title="Permalink to this definition"></a></dt>
<dd><p>Mark the wrapped expression as safe (wrap it as <cite>Markup</cite>) but
only if autoescaping is active.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 2.5.</span></p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Name">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Name</tt><big>(</big><em>name</em>, <em>ctx</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Name" title="Permalink to this definition"></a></dt>
<dd><p>Looks up a name or stores a value in a name.
The <cite>ctx</cite> of the node can be one of the following values:</p>
<ul class="simple">
<li><cite>store</cite>: store a value in the name</li>
<li><cite>load</cite>: load that name</li>
<li><cite>param</cite>: like <cite>store</cite> but if the name was defined as function parameter.</li>
</ul>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Slice">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Slice</tt><big>(</big><em>start</em>, <em>stop</em>, <em>step</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Slice" title="Permalink to this definition"></a></dt>
<dd><p>Represents a slice object.  This must only be used as argument for
<tt class="xref py py-class docutils literal"><span class="pre">Subscript</span></tt>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Test">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Test</tt><big>(</big><em>node</em>, <em>name</em>, <em>args</em>, <em>kwargs</em>, <em>dyn_args</em>, <em>dyn_kwargs</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Test" title="Permalink to this definition"></a></dt>
<dd><p>Applies a test on an expression.  <cite>name</cite> is the name of the test, the
rest of the fields are the same as for <a class="reference internal" href="#jinja2.nodes.Call" title="jinja2.nodes.Call"><tt class="xref py py-class docutils literal"><span class="pre">Call</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.UnaryExpr">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">UnaryExpr</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#jinja2.nodes.UnaryExpr" title="Permalink to this definition"></a></dt>
<dd><p>Baseclass for all unary expressions.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Expr" title="jinja2.nodes.Expr"><tt class="xref py py-class docutils literal"><span class="pre">Expr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Neg">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Neg</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Neg" title="Permalink to this definition"></a></dt>
<dd><p>Make the expression negative.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.UnaryExpr" title="jinja2.nodes.UnaryExpr"><tt class="xref py py-class docutils literal"><span class="pre">UnaryExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Not">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Not</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Not" title="Permalink to this definition"></a></dt>
<dd><p>Negate the expression.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.UnaryExpr" title="jinja2.nodes.UnaryExpr"><tt class="xref py py-class docutils literal"><span class="pre">UnaryExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Pos">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Pos</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Pos" title="Permalink to this definition"></a></dt>
<dd><p>Make the expression positive (noop for most expressions)</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.UnaryExpr" title="jinja2.nodes.UnaryExpr"><tt class="xref py py-class docutils literal"><span class="pre">UnaryExpr</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Helper">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Helper</tt><a class="headerlink" href="#jinja2.nodes.Helper" title="Permalink to this definition"></a></dt>
<dd><p>Nodes that exist in a specific context only.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Node" title="jinja2.nodes.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Keyword">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Keyword</tt><big>(</big><em>key</em>, <em>value</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Keyword" title="Permalink to this definition"></a></dt>
<dd><p>A key, value pair for keyword arguments where key is a string.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Helper" title="jinja2.nodes.Helper"><tt class="xref py py-class docutils literal"><span class="pre">Helper</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Operand">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Operand</tt><big>(</big><em>op</em>, <em>expr</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Operand" title="Permalink to this definition"></a></dt>
<dd><p>Holds an operator and an expression.
The following operators are available: <tt class="docutils literal"><span class="pre">%</span></tt>, <tt class="docutils literal"><span class="pre">**</span></tt>, <tt class="docutils literal"><span class="pre">*</span></tt>, <tt class="docutils literal"><span class="pre">+</span></tt>, <tt class="docutils literal"><span class="pre">-</span></tt>, <tt class="docutils literal"><span class="pre">//</span></tt>, <tt class="docutils literal"><span class="pre">/</span></tt>, <tt class="docutils literal"><span class="pre">eq</span></tt>, <tt class="docutils literal"><span class="pre">gt</span></tt>, <tt class="docutils literal"><span class="pre">gteq</span></tt>, <tt class="docutils literal"><span class="pre">in</span></tt>, <tt class="docutils literal"><span class="pre">lt</span></tt>, <tt class="docutils literal"><span class="pre">lteq</span></tt>, <tt class="docutils literal"><span class="pre">ne</span></tt>, <tt class="docutils literal"><span class="pre">not</span></tt>, <tt class="docutils literal"><span class="pre">notin</span></tt></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Helper" title="jinja2.nodes.Helper"><tt class="xref py py-class docutils literal"><span class="pre">Helper</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Pair">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Pair</tt><big>(</big><em>key</em>, <em>value</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Pair" title="Permalink to this definition"></a></dt>
<dd><p>A key, value pair for dicts.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Helper" title="jinja2.nodes.Helper"><tt class="xref py py-class docutils literal"><span class="pre">Helper</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Stmt">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Stmt</tt><a class="headerlink" href="#jinja2.nodes.Stmt" title="Permalink to this definition"></a></dt>
<dd><p>Base node for all statements.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Node" title="jinja2.nodes.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Assign">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Assign</tt><big>(</big><em>target</em>, <em>node</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Assign" title="Permalink to this definition"></a></dt>
<dd><p>Assigns an expression to a target.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.AssignBlock">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">AssignBlock</tt><big>(</big><em>target</em>, <em>body</em><big>)</big><a class="headerlink" href="#jinja2.nodes.AssignBlock" title="Permalink to this definition"></a></dt>
<dd><p>Assigns a block to a target.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Block">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Block</tt><big>(</big><em>name</em>, <em>body</em>, <em>scoped</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Block" title="Permalink to this definition"></a></dt>
<dd><p>A node that represents a block.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Break">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Break</tt><a class="headerlink" href="#jinja2.nodes.Break" title="Permalink to this definition"></a></dt>
<dd><p>Break a loop.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.CallBlock">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">CallBlock</tt><big>(</big><em>call</em>, <em>args</em>, <em>defaults</em>, <em>body</em><big>)</big><a class="headerlink" href="#jinja2.nodes.CallBlock" title="Permalink to this definition"></a></dt>
<dd><p>Like a macro without a name but a call instead.  <cite>call</cite> is called with
the unnamed macro as <cite>caller</cite> argument this node holds.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Continue">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Continue</tt><a class="headerlink" href="#jinja2.nodes.Continue" title="Permalink to this definition"></a></dt>
<dd><p>Continue a loop.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.EvalContextModifier">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">EvalContextModifier</tt><big>(</big><em>options</em><big>)</big><a class="headerlink" href="#jinja2.nodes.EvalContextModifier" title="Permalink to this definition"></a></dt>
<dd><p>Modifies the eval context.  For each option that should be modified,
a <a class="reference internal" href="#jinja2.nodes.Keyword" title="jinja2.nodes.Keyword"><tt class="xref py py-class docutils literal"><span class="pre">Keyword</span></tt></a> has to be added to the <tt class="xref py py-attr docutils literal"><span class="pre">options</span></tt> list.</p>
<p>Example to change the <cite>autoescape</cite> setting:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">EvalContextModifier</span><span class="p">(</span><span class="n">options</span><span class="o">=</span><span class="p">[</span><span class="n">Keyword</span><span class="p">(</span><span class="s">&#39;autoescape&#39;</span><span class="p">,</span> <span class="n">Const</span><span class="p">(</span><span class="bp">True</span><span class="p">))])</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.ScopedEvalContextModifier">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">ScopedEvalContextModifier</tt><big>(</big><em>options</em>, <em>body</em><big>)</big><a class="headerlink" href="#jinja2.nodes.ScopedEvalContextModifier" title="Permalink to this definition"></a></dt>
<dd><p>Modifies the eval context and reverts it later.  Works exactly like
<a class="reference internal" href="#jinja2.nodes.EvalContextModifier" title="jinja2.nodes.EvalContextModifier"><tt class="xref py py-class docutils literal"><span class="pre">EvalContextModifier</span></tt></a> but will only modify the
<a class="reference internal" href="api.html#jinja2.nodes.EvalContext" title="jinja2.nodes.EvalContext"><tt class="xref py py-class docutils literal"><span class="pre">EvalContext</span></tt></a> for nodes in the <tt class="xref py py-attr docutils literal"><span class="pre">body</span></tt>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.EvalContextModifier" title="jinja2.nodes.EvalContextModifier"><tt class="xref py py-class docutils literal"><span class="pre">EvalContextModifier</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.ExprStmt">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">ExprStmt</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#jinja2.nodes.ExprStmt" title="Permalink to this definition"></a></dt>
<dd><p>A statement that evaluates an expression and discards the result.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Extends">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Extends</tt><big>(</big><em>template</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Extends" title="Permalink to this definition"></a></dt>
<dd><p>Represents an extends statement.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.FilterBlock">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">FilterBlock</tt><big>(</big><em>body</em>, <em>filter</em><big>)</big><a class="headerlink" href="#jinja2.nodes.FilterBlock" title="Permalink to this definition"></a></dt>
<dd><p>Node for filter sections.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.For">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">For</tt><big>(</big><em>target</em>, <em>iter</em>, <em>body</em>, <em>else_</em>, <em>test</em>, <em>recursive</em><big>)</big><a class="headerlink" href="#jinja2.nodes.For" title="Permalink to this definition"></a></dt>
<dd><p>The for loop.  <cite>target</cite> is the target for the iteration (usually a
<a class="reference internal" href="#jinja2.nodes.Name" title="jinja2.nodes.Name"><tt class="xref py py-class docutils literal"><span class="pre">Name</span></tt></a> or <a class="reference internal" href="#jinja2.nodes.Tuple" title="jinja2.nodes.Tuple"><tt class="xref py py-class docutils literal"><span class="pre">Tuple</span></tt></a>), <cite>iter</cite> the iterable.  <cite>body</cite> is a list
of nodes that are used as loop-body, and <cite>else_</cite> a list of nodes for the
<cite>else</cite> block.  If no else node exists it has to be an empty list.</p>
<p>For filtered nodes an expression can be stored as <cite>test</cite>, otherwise <cite>None</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.FromImport">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">FromImport</tt><big>(</big><em>template</em>, <em>names</em>, <em>with_context</em><big>)</big><a class="headerlink" href="#jinja2.nodes.FromImport" title="Permalink to this definition"></a></dt>
<dd><p>A node that represents the from import tag.  It&#8217;s important to not
pass unsafe names to the name attribute.  The compiler translates the
attribute lookups directly into getattr calls and does <em>not</em> use the
subscript callback of the interface.  As exported variables may not
start with double underscores (which the parser asserts) this is not a
problem for regular Jinja code, but if this node is used in an extension
extra care must be taken.</p>
<p>The list of names may contain tuples if aliases are wanted.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.If">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">If</tt><big>(</big><em>test</em>, <em>body</em>, <em>else_</em><big>)</big><a class="headerlink" href="#jinja2.nodes.If" title="Permalink to this definition"></a></dt>
<dd><p>If <cite>test</cite> is true, <cite>body</cite> is rendered, else <cite>else_</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Import">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Import</tt><big>(</big><em>template</em>, <em>target</em>, <em>with_context</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Import" title="Permalink to this definition"></a></dt>
<dd><p>A node that represents the import tag.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Include">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Include</tt><big>(</big><em>template</em>, <em>with_context</em>, <em>ignore_missing</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Include" title="Permalink to this definition"></a></dt>
<dd><p>A node that represents the include tag.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Macro">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Macro</tt><big>(</big><em>name</em>, <em>args</em>, <em>defaults</em>, <em>body</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Macro" title="Permalink to this definition"></a></dt>
<dd><p>A macro definition.  <cite>name</cite> is the name of the macro, <cite>args</cite> a list of
arguments and <cite>defaults</cite> a list of defaults if there are any.  <cite>body</cite> is
a list of nodes for the macro body.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Output">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Output</tt><big>(</big><em>nodes</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Output" title="Permalink to this definition"></a></dt>
<dd><p>A node that holds multiple expressions which are then printed out.
This is used both for the <cite>print</cite> statement and the regular template data.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Scope">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Scope</tt><big>(</big><em>body</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Scope" title="Permalink to this definition"></a></dt>
<dd><p>An artificial scope.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Stmt" title="jinja2.nodes.Stmt"><tt class="xref py py-class docutils literal"><span class="pre">Stmt</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="jinja2.nodes.Template">
<em class="property">class </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Template</tt><big>(</big><em>body</em><big>)</big><a class="headerlink" href="#jinja2.nodes.Template" title="Permalink to this definition"></a></dt>
<dd><p>Node that represents a template.  This must be the outermost node that
is passed to the compiler.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Node type:</th><td class="field-body"><a class="reference internal" href="#jinja2.nodes.Node" title="jinja2.nodes.Node"><tt class="xref py py-class docutils literal"><span class="pre">Node</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="exception">
<dt id="jinja2.nodes.Impossible">
<em class="property">exception </em><tt class="descclassname">jinja2.nodes.</tt><tt class="descname">Impossible</tt><a class="headerlink" href="#jinja2.nodes.Impossible" title="Permalink to this definition"></a></dt>
<dd><p>Raised if the node could not perform a requested action.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="index.html">
  <img class="logo" src="_static/jinja-small.png" alt="Logo"/>
</a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Extensions</a><ul>
<li><a class="reference internal" href="#adding-extensions">Adding Extensions</a></li>
<li><a class="reference internal" href="#i18n-extension">i18n Extension</a><ul>
<li><a class="reference internal" href="#environment-methods">Environment Methods</a></li>
<li><a class="reference internal" href="#newstyle-gettext">Newstyle Gettext</a></li>
</ul>
</li>
<li><a class="reference internal" href="#expression-statement">Expression Statement</a></li>
<li><a class="reference internal" href="#loop-controls">Loop Controls</a></li>
<li><a class="reference internal" href="#with-statement">With Statement</a></li>
<li><a class="reference internal" href="#autoescape-extension">Autoescape Extension</a></li>
<li><a class="reference internal" href="#module-jinja2.ext">Writing Extensions</a><ul>
<li><a class="reference internal" href="#example-extension">Example Extension</a></li>
<li><a class="reference internal" href="#extension-api">Extension API</a></li>
<li><a class="reference internal" href="#parser-api">Parser API</a></li>
<li><a class="reference internal" href="#ast">AST</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="templates.html" title="previous chapter">Template Designer Documentation</a></li>
      <li>Next: <a href="integration.html" title="next chapter">Integration</a></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/extensions.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Armin Ronacher.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>