Unreleased
Released 2022-04-28
Released 2022-03-25
Released 2022-03-24
Remove previously deprecated code. #1544
WithExtension and AutoEscapeExtension are built-in now.contextfilter and contextfunction are replaced by pass_context. evalcontextfilter and evalcontextfunction are replaced by pass_eval_context. environmentfilter and environmentfunction are replaced by pass_environment.Markup and escape should be imported from MarkupSafe.Context subclasses is no longer supported. Override resolve_or_missing instead of resolve.unicode_urlencode is renamed to url_quote.{% trans %} tag can use pgettext and npgettext by passing a context string as the first token in the tag, like {% trans "title" %}. #1430
@async_variant are pickleable. #1612
items filter. #1561
[0], etc.) can be used after filters, tests, and calls when the environment is in async mode. #1573
groupby filter is case-insensitive by default, matching other comparison filters. Added the case_sensitive parameter to control this. #1463
FileSystemLoader and PackageLoader loading from drive-relative paths. #1621
Released 2021-11-09
hash(Node) behavior. Nodes are hashed by id again #1521
PackageLoader works when the package is a single module file. #1512
Released 2021-10-04
compile_templates deterministic for filter and import names. #1452, #1453
Undefined to act like StrictUndefined for the in operator. #1448
PackageLoader will not include a current directory (.) path segment. This allows loading templates from the root of a zip import. #1467
Released 2021-05-18
autoescape and with_ extensions shows more relevant context. #1429
jinja2.Markup without an argument. Use markupsafe.Markup instead. #1438
render for an async template uses asyncio.run on Python >= 3.7. This fixes a deprecation that Python 3.10 introduces. #1443
Released 2021-05-11
PackageLoader. #1168
trim_blocks using +%}. #1036
Undefined being returned on NativeEnvironment on Python 3.10. #1335
required. They must be overridden at some point, but not necessarily by the direct child. #1147
autoescape and with extensions, they are built-in to the compiler. #1203
urlize filter recognizes mailto: links and takes extra_schemes (or env.policies["urlize.extra_schemes"]) to recognize other schemes. It tries to balance parentheses within a URL instead of ignoring trailing characters. The parsing in general has been updated to be more efficient and match more cases. URLs without a scheme are linked as https:// instead of http://. #522, #827, #1172, #1195
map and groupby, can use a false or empty value as a default. #1331
Environment.get_template(globals=...) even if the template was already loaded. #295
is filter and is test tests to test if a name is a registered filter or test. This allows checking if a filter is available in a template before using it. Test functions can be decorated with @pass_environment, @pass_eval_context, or @pass_context. #842, #1248
pgettext and npgettext (message contexts) in i18n extension. #441
|indent filter’s width argument can be a string to indent by. #1167
Undefined.__contains__ (in) raises an UndefinedError instead of a TypeError. #1198
Undefined is iterable in an async environment. #1294
NativeEnvironment supports async mode. #1362
\n, \r\n and \r as line breaks. Other characters are left unchanged. #769, #952, #1313
|groupby filter takes an optional default argument. #1359
The function and filter decorators have been renamed and unified. The old names are deprecated. #1381
pass_context replaces contextfunction and contextfilter.pass_eval_context replaces evalcontextfunction and evalcontextfilter
pass_environment replaces environmentfunction and environmentfilter.Environment(enable_async=True). #1390
Context.resolve is deprecated, override resolve_or_missing instead. #1380
Released 2021-01-31
urlize filter by reducing regex backtracking. Email matching requires a word character at the start of the domain part, and only word characters in the TLD. #1343
Released 2020-04-13
__getattr__, like Mock to be treated as a contextfunction(). #1145
wordcount filter to trigger Undefined methods by wrapping the input in soft_str(). #1160
AttributeError on access doesn’t cause a recursion error. #1177
PackageLoader from 2.10 which removed the dependency on setuptools and pkg_resources, and added limited support for namespace packages. The changes caused issues when using Pytest. Due to the difficulty in supporting Python 2 and PEP 451 simultaneously, the changes are reverted until 3.0. #1182
namespace() assignment object in templates works in async environments. #1180
lstrip_blocks is enabled. #1138
NativeEnvironment doesn’t evaluate intermediate strings during rendering. This prevents early evaluation which could change the value of an expression. #1186
Released 2020-01-30
{{ data.items[1:] }}) in an async template. #1141
Released 2020-01-27
ChainableUndefined class to support getitem and getattr on an undefined object. #977
{%+ syntax (with NOP behavior) when lstrip_blocks is disabled. #748
default parameter for the map filter. #557
meta.find_undeclared_variables(). #931
LRUCache.setdefault. #1000
trim filter takes an optional string of characters to trim. #828
jinja2.ext.debug extension adds a {%+ syntax (with NOP behavior) when lstrip_blocks is disabled. #748
default parameter for the map filter. #557
meta.find_undeclared_variables(). #931
LRUCache.setdefault. #1000
trim filter takes an optional string of characters to trim. #828
jinja2.ext.debug extension adds a {% debug %} tag to quickly dump the current context and available filters and tests. #174, #798, #983
{{ 2 * (3 < 5) }} outputs “2” instead of “False”. #755, #938
boolean, false, true, integer and float tests. #824
finalize function is only applied to the output of expressions (constant or not), not static template data. #63
FileSystemLoader, a template can have the same name as a directory. #821
Undefined when omitting the else clause in a {{ 'foo' if bar }} expression, regardless of the environment’s undefined class. Omitting the else clause is a valid shortcut and should not raise an error when using StrictUndefined. #710, #1079
loop control variables such as length and revindex0 when looping over a generator. #459, #751, #794, #993
|map filter will await the filter call if needed. #913
loop attributes, the iterator is not advanced ahead of the current iteration unless length, revindex, nextitem, or last are accessed. This makes it less likely to break groupby results. #555, #1101
loop attributes length and revindex work for async iterators. #1101
PackageLoader doesn’t depend on setuptools or pkg_resources. #970
PackageLoader has limited support for PEP 420 namespace packages. #1097
os.PathLike objects in FileSystemLoader and ModuleLoader. #870
NativeTemplate correctly handles quotes between expressions. "'{{ a }}', '{{ b }}'" renders as the tuple ('1', '2') rather than the string '1, 2'. #1020
NativeTemplate directly creates a NativeEnvironment instead of a default Environment. #1091
LRUCache.copy(), the copy’s queue methods point to the correct queue. #843
|wordwrap filter treats existing newlines as separate paragraphs to be wrapped individually, rather than creating short intermediate lines. #175
break_on_hyphens parameter to |wordwrap filter. #550
False if any comparison returns False, rather than only the last one. #1102
DerivedContextReference node that can be used by extensions to get the current context and local variables such as loop. #860
TemplateSyntaxError.source is not empty when raised from an included template. #457
Undefined value to get_template (such as through extends, import, or include), raises an UndefinedError consistently. select_template will show the undefined message in the list of attempts rather than the empty string. #1037
TemplateSyntaxError can be pickled. #1117
Released 2019-10-04
setup.py that was preventing installation.Released 2019-10-04
Released 2019-04-06
SandboxedEnvironment securely handles str.format_map in order to prevent code execution through untrusted format strings. The sandbox already handled str.format.Released 2017-11-08
OverlayScope which can be used to create an unoptimized scope that will look up all variables from a derived context.in test that works like the in operator. This can be used in combination with reject and select.previtem and nextitem to loop contexts, providing access to the previous/next item in the loop. If such an item does not exist, the value is undefined.changed(*values) to loop contexts, providing an easy way of checking whether a value has changed since the last iteration (or rather since the last call of the method)namespace function that creates a special object which allows attribute assignment using the set tag. This can be used to carry data across scopes, e.g. from a loop body to code that comes after the loop.trimmed modifier to {% trans %} to strip linebreaks and surrounding whitespace. Also added a new policy to enable this for all trans blocks.random filter is no longer incorrectly constant folded and will produce a new random choice each time the template is rendered. #478
unique filter. #469
min and max filters. #475
eq, ne, lt, le, gt, ge. #665
import statement cannot end with a trailing comma. #617, #618
indent filter will not indent blank lines by default. #685
reverse argument for dictsort filter. #692
NativeEnvironment that renders templates to native Python types instead of strings. #708
set tag. #489
tojson filter marks output as safe to match documented behavior. #718
{% elif ... %} blocks resulted in a “too many levels of indentation” error. These blocks now compile to native elif ..: instead of else: if ..: #759
Released 2017-04-03
Released 2017-01-28
_GroupTuple because this caused issues with ansible and it was an unintended change. #654
resolve method since it was hard for people to spot that this could cause a regression.{% extends %} tag could not be used with async environments. #668
Released 2017-01-10
truncate.leeway default configurable to improve compatibility with older templates.Released 2017-01-08
block scoped would not take advantage of the new scoping rules. In some more exotic cases a variable overridden in a local scope would not make it into a block.with statement to be in line with the new scoping rules. This resolves some unlikely bugs in edge cases. This also introduces a new internal With node that can be used by extensions.Released 2017-01-08
Released 2017-01-07
Released 2017-01-07, codename Derivation
generator_stop on supported Python versions (Python 3.5 and later)map and friends will now give better error messages if you forgot to quote the parameter.truncate filter to support better truncation in case the string is barely truncated at all.tojson filter from Flask to Jinja and hooked it up with the new policy framework.safe by default.compiler.ascii_str policy.foo is divisibleby 2 or foo is
divisibleby 3 as you would expect.with context and without
context.with and autoescape tags are now built-in.select_autoescape function which helps configuring better autoescaping easier.Released 2016-12-29
for_qs flag for urlencode.int to non-string values.Released 2015-07-26, codename Replacement
target parameter to urlize function.followsymlinks to the file system loader.make_logging_undefined which returns an undefined object that logs failures into a logger.set tag.is number test to accept long integers in all Python versions.is number to accept Decimal as a number.{% macro m(x, y=1, z) %} a syntax error. The previous behavior for this code was broken anyway (resulting in the default value being applied to y).jinja2.compiler.CodeGenerator and jinja2.runtime.Context by adding two new attributes to the environment (code_generator_class and context_class). #404
Released 2014-06-06
Released 2014-01-10
Released 2013-08-07
call_filter not working properly on environment and context filters.Released 2013-05-20, codename Translation
urlencode filter that automatically quotes values for URL safe usage with utf-8 as only supported encoding. If applications want to change this encoding they can override the filter.keep-trailing-newline configuration to environments and templates to optionally preserve the final trailing newline.last on the loop context no longer causes the iterator to be consumed into a list.contextfunction and other decorators to be applied to __call__.wordwrap filter.map, select, reject, selectattr and rejectattr filters.loop.depth to figure out how deep inside a recursive loop the code is.Released 2011-07-24, codename Convolution
Released 2010-10-18
Released 2010-10-17
Released 2010-10-17
Released 2010-08-18
--with-speedups).Released 2010-08-17
num in newstyle gettext for something else than the pluralize count will no longer raise a KeyError.Released 2010-05-29, codename Incoherence
Released 2010-04-20
Released 2010-04-13, codename Correlation
ModuleLoader that can load templates from precompiled sources. The environment now features a method to compile the templates from a configured loader into a zip file or folder.Released 2010-02-19
Released 2010-02-10, codename 3000 Pythons
{% if %} a syntax error now. #364
Released 2009-09-14
Released 2009-09-13, codename Kong
ignore missing to skip non existing templates.not raised. It’s now possible to write not foo in
bar as an alias to foo not in bar like in python. Previously the grammar required parentheses (not (foo in bar)) which was odd.{% call %} tag inside loops.{{ foo[1, 2] }} impossible.scoped modifier to blocks.meta module.Released 2008-12-25
Released 2008-11-23, codename Yasuzō
{{ foo.0.0 }} impossible.foo.ugettext now followed by foo.gettext if an translations object is installed. This makes dealing with custom translations classes easier.sort filter that works like dictsort but for arbitrary sequences.cycler.joiner.compile_expression method to the environment that allows compiling of Jinja expressions into callable Python objects.Released 2008-07-17, codename Jinjavitus
Subscript is gone and was replaced with Getitem and Getattr.TemplateStream.dump.{{ "foo" "bar" }} is equivalent to {{ "foobar" }}
else is optional for conditional expressions. If not given it evaluates to false.filesizeformat filter uses decimal prefixes now per default and can be set to binary mode with the second parameter.Released 2008-06-09
© 2007–2021 Pallets
Licensed under the BSD 3-clause License.
https://jinja.palletsprojects.com/en/3.1.x/changes/