Commit Graph

42 Commits

Author SHA1 Message Date
SamyCookie
e45bc745a7
Bugfix: wrong default argument for Environment.overlay(enable_async) parameter 2024-12-19 18:22:32 -08:00
Matt Davis
d4fb0e8c40
preserve __slots__ on Undefined classes 2024-12-19 08:11:49 -08:00
David Lord
0ee5eb41d1
satisfy formatter, linter, and strict mypy 2024-04-23 09:29:26 -07:00
Joachim Jablon
d5f49f5cc1
Fixes #1448: Revert Undefined.__contains__ to 2.x behaviour 2021-08-09 11:07:35 -07:00
Danny Sepler
06c646df2d
Use pathlib in some test places 2021-05-18 10:30:11 -07:00
David Lord
788d8bc172
unify/rename filter and function decorators
Use pass_context instead of contextfilter and contextfunction, etc.
2021-04-10 10:14:42 -07:00
David Parker
609bcb0831
Undefined.__contains__ raises UndefinedError 2021-04-05 10:44:31 -07:00
Teymour Aldridge
50ae5b6ac7 Setup mypy
* Add missing type hints (these are intended as an initial set of type hints, to be added upon and improved later)
* Setup MyPy to run as a Github Action
2020-07-28 22:32:34 +01:00
David Lord
c074fd5ecb
Merge branch '2.11.x' 2020-03-30 10:54:57 -07:00
David Lord
f15452f130
AttributeError in undefined message doesn't cause RuntimeError 2020-03-27 09:51:53 -07:00
David Lord
e08dadd220
Merge branch '2.11.x' 2020-02-05 20:39:04 -08:00
David Lord
dd5a0508c5
remove custom pytest marks 2020-02-05 20:23:47 -08:00
David Lord
2a8515d2e5
apply pyupgrade and f-strings 2020-02-05 08:44:15 -08:00
David Lord
60293416db
remove more compat code 2020-02-05 08:37:40 -08:00
David Lord
4a59ac9514
Revert "rename imports to jinja"
This reverts commit 1167525b73.
2020-01-26 21:12:52 -08:00
David Lord
1167525b73
rename imports to jinja 2020-01-10 15:30:16 -08:00
David Lord
51c1c8efa6
simplify module docstrings 2020-01-10 13:42:02 -08:00
David Lord
bb6216ea30
apply flake8 2020-01-10 10:40:52 -08:00
David Lord
04c8787155
apply black 2020-01-10 07:54:39 -08:00
David Lord
d177eeb295
apply reorder-python-imports 2020-01-10 07:54:39 -08:00
David Lord
2ec62dc414
handle Undefined in get/select_template 2019-12-05 13:46:36 -08:00
David Lord
3487c8e087
refactor visit_Output
* `finalize` is generated once and cached for all nodes.
* Extract common behavior for native env.

Removed the compiler behavior where groups of nodes would generate a
format string. Instead, individual nodes are always yielded. This made
rendering 30% faster in the examples, and simplifies the code. It also
removes the issue where Python would report either the first or last
line of the multi-line format expression, messing up the traceback line
number mapping.
2019-11-20 14:09:44 -08:00
Adrian Moennich
4d331a0ae3 Don't make cond_expr_undefined configurable 2019-10-13 16:54:35 +02:00
Adrian Moennich
c4d39969e2 Use separate undefined object for CondExpr 2019-10-13 16:32:02 +02:00
David Lord
719537aeec
don't finalize TemplateData nodes
Finalize only applies to the output of expressions (constant or not).
Add tests for context, eval, and env finalize functions.
2019-10-12 21:25:48 -07:00
Kevin Brown
ca72c5f301 Replaced try...catch within tests with pytest.raises
This still leaves one in test_debug which relies on reading out
the traceback and cannot easily be replaced by pytest.raises
like the others.
2019-10-10 02:32:29 -04:00
btharper
051b5217bf Eliminate dead code by using pytests.raises instead of try/except/else 2019-10-06 00:00:24 -04:00
EtiennePelletier
69d8d98860
Add tests for Undefined classes 2019-10-04 08:25:36 -07:00
David Lord
9550dc85ff
Merge branch '2.10.x' 2019-07-26 15:21:16 -07:00
Brendan
f7b110cbd0
exclude globals from find_undeclared_variables 2019-07-22 10:43:47 -07:00
Prakhar Bhandari
35fcd9fef2
sandbox uses xrange on Python 2 2019-07-22 08:30:22 -07:00
Étienne Pelletier
19133d4059 Add ChainableUndefined allowing getattr & getitem (#997)
* Add ChainableUndefined allowing getattr & getitem

Allows using default values with chains of items or attributes that may
contain undefined values without raising a jinja2.exceptions.UndefinedError.

>>> import jinja2
>>> env = jinja2.Environment(undefined=jinja2.ChainableUndefined)
>>> env.from_string("{{ foo.bar['baz'] | default('val') }}").render()
'val'

* Remove class decorator from ChainableUndefined
2019-05-08 10:47:33 -04:00
Jon Dufresne
148b6fb3c5 Trim trailing white space throughout the project
Many editors clean up trailing white space on save. By removing it all
in one go, it helps keep future diffs cleaner by avoiding spurious white
space changes on unrelated lines.
2018-08-29 20:58:03 -07:00
Armin Ronacher
bbe0a4174c Bump up the copyright to 2017 2017-01-07 16:17:14 +01:00
Armin Ronacher
73e2b51052 Cleaned up shitty syntax in testsuite 2017-01-06 21:00:01 +01:00
Armin Ronacher
058bc8a98d Fixed various breakage from the new id tracking 2017-01-03 23:45:29 +01:00
Armin Ronacher
479d870eba Merge pull request #530 from nick-garcia/master
Subtraction from Undefined does not raise UndefinedError
2017-01-03 19:31:01 +01:00
Nick Garcia
dd85761ced Setting __sub__ equal to _fail_with_undefined_error so subtractions with
undefined variables will fail properly like other arithemtic operations.
2016-01-07 15:23:26 -08:00
Matt Haggard
77781b93a5 Give Cycler a next() method so that it works in python2 and 3 2015-12-29 16:12:39 -07:00
ThiefMaster
f22fdd5ffe Let the Environment override the Context
closes #404
2015-04-06 14:19:43 +02:00
ThiefMaster
14936312c0 Let the Environment override the CodeGenerator
see #404
2015-04-06 14:17:19 +02:00
Kartheek Lenkala
ee2cb97449 Rename testsuite to tests and suggestions
Remove  py.test from setup.py install_requires
Rename testsuite folder to tests.
2015-03-22 18:03:14 +05:30