- Added a `trimmed` modifier to `{% trans %}` to strip linebreaks and
surrounding whitespace. Also added a new policy to enable this for all
`trans` blocks.
+- The ``random`` filter is no longer incorrectly constant folded and will
+ produce a new random choice each time the template is rendered. (`#478`_)
+
+.. _#478: https://github.com/pallets/jinja/pull/478
Version 2.9.6
-------------
state = random.getstate()
request.addfinalizer(lambda: random.setstate(state))
# generate the random values from a known seed
- random.seed('jinja', version=2)
+ random.seed('jinja')
expected = [random.choice('1234567890') for _ in range(10)]
# check that the random sequence is generated again by a template
# ensures that filter result is not constant folded
- random.seed('jinja', version=2)
+ random.seed('jinja')
t = env.from_string('{{ "1234567890"|random }}')
for value in expected: