Commit Graph

56 Commits

Author SHA1 Message Date
Kevin Brown-Silva
66587ce989
Fix bug where set would sometimes fail within if
There was a bug that came as the result of an early optimization done
within ID tracking that caused loading parameters to fail in a very
specific and rare edge case. That edge case only occurred when the
parameter was being set within all 3 standard branches of an if block,
since the optimization would assume that the parameter was never being
referenced and was only ever being set. This would cause the variable to
be set to undefined.

The fix for this was to remove the optimization and still continue to
load in the parameter even if it is set in all 3 branches.
2024-12-21 09:40:06 -08:00
Rens Groothuijsen
d05bd3858c
Pass context when using select 2024-12-19 20:47:24 -08:00
David Lord
0ee5eb41d1
satisfy formatter, linter, and strict mypy 2024-04-23 09:29:26 -07:00
David Lord
6faf093f9d
remove deprecated legacy resolve mode for context subclass 2021-11-10 11:07:04 -08:00
Amy
f3bc9c6a91
clear assignments in loops at end of iteration 2021-05-21 11:24:04 -07:00
David Lord
912e59d51f
deprecate legacy resolve mode 2021-04-11 23:53:59 -07:00
David Lord
aafe94d97a
Markup and escape should be imported from markupsafe 2021-04-10 10:22:24 -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
Matěj Volf
9dae67bcc8
Split lines in lexer only by \r\n, \r and \n
Python str.splitlines() splits by more characters[1], which, however,
causes problems when keeping these special characters in processed
templates is desirable, i.e. these bug reports: #769, #952, #1313.

The keep_trailing_newlines logic is reworked because splitlines()
removes them already (so they had to be added), while re.split doesn't
so they have to be removed.

[1] https://docs.python.org/3/library/stdtypes.html#str.splitlines
2021-04-05 11:46:36 -07:00
David Lord
38e45fead3
more detailed docs about globals 2021-03-31 16:09:51 -07:00
Amy
49d5f9788c fix bug with cached templates not using new globals 2021-03-30 01:43:51 -04:00
Amy
f524bcce0c track local loop/block vars for contextfunctions 2021-03-26 16:45:25 -04:00
Bebleo
d504e1d1e2
Improve and extend urlize 2021-01-30 06:25:03 -08:00
FawziyahAlebiosu
1843d6d411 deprecate 'with' and 'autoescape' extensions 2021-01-29 16:56:47 -05: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
148a19138c
remove _compat module 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
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
Laurence de Bruxelles
8afc7e57c9
Fix bug with when using Markup on ChainableUndefined
Wrapping a ChainableUndefined object with Markup causes an
UndefinedError because Markup thinks that ChainableUndefined has an
attribute called __html__ and tries to call it.

This commit fixes this by defining a method __html__ that calls
ChainableUndefined.__str__. We also add a regression test.
2019-10-04 13:06:12 -07:00
eplata31
9b38bb434a BUGFIX #930 - Template parse if with when referencing with dictionary subproperty 2019-05-13 15:46:41 -05:00
Jon Dufresne
0f00f8ec79 Remove print() output during test
Looks like it was left in from debugging.
2017-04-09 14:29:17 -07:00
Adrian Moennich
a8a9ec2f29 Fix custom contexts in fast resolve mode
closes #675
2017-03-15 19:19:04 +01:00
Armin Ronacher
ca124c5cfe Correctly use buffer for else frame in loops. Fixes #669 2017-01-24 20:16:02 +01:00
Armin Ronacher
c6ddeb7d5f Add support back for custom resolves on old resolve method 2017-01-12 20:10:58 +01:00
Armin Ronacher
f30f5d8b4d Also restore original str method 2017-01-12 15:55:20 +01:00
Armin Ronacher
785485114f Restore original tuple repr for grouper. Fixes #654 2017-01-12 15:53:12 +01:00
Armin Ronacher
716cfb7537 Added another regression test for ansible/ansible#20063 2017-01-12 15:43:31 +01:00
Armin Ronacher
3e9937cd95 Added a test for an assumed regression (refs #659) 2017-01-12 15:38:31 +01:00
Armin Ronacher
e73c574c21 Resolved bad code generation on toplevel ifs
This fixes #651
2017-01-09 16:50:55 +01:00
Armin Ronacher
ef718011e5 Correctly scope loop filters. Fixes #649 2017-01-09 12:23:18 +01:00
Armin Ronacher
b1a56de18a Support new scoping rules in scoped blocks 2017-01-08 11:21:32 +01:00
Armin Ronacher
6f7fa5cdcd Do not use yield from for blocks with buffers. Fixes #645 2017-01-08 09:27:11 +01:00
Armin Ronacher
6235644d33 Add support for explicit callers
This adds support for a never intended Jinja2 feature which however
worked in limited support before due to a bug with the identifier
scoping.  A quick github code search indicates that developers
commonly did this to set the default caller to none.

This fixes #642
2017-01-08 02:16:41 +01:00
Armin Ronacher
e3022523a5 Correct bad scoping for for loops. This fixes #640 2017-01-07 23:15:07 +01:00
Armin Ronacher
2c74f2468b Resolved a regression in 2.9 with macro call scoping 2017-01-07 16:54:57 +01:00
Armin Ronacher
bbe0a4174c Bump up the copyright to 2017 2017-01-07 16:17:14 +01:00
Armin Ronacher
d67f0fd4cc Generalize scoping. This fixes #603 2017-01-07 15:35:50 +01:00
Armin Ronacher
894ddb1b36 Added a test for macro scoping in loops 2017-01-06 21:48:53 +01:00
Armin Ronacher
73e2b51052 Cleaned up shitty syntax in testsuite 2017-01-06 21:00:01 +01:00
Armin Ronacher
6eca1aefdd Added a missing test 2017-01-06 13:00:19 +01:00
Armin Ronacher
9b2a4f49c6 Changed behavior of macro defaults to be frame bound 2017-01-03 23:45:30 +01:00
Armin Ronacher
5ab69f24f9 Checked in a failing test 2017-01-03 23:45:30 +01:00
Armin Ronacher
0fc73b16c0 Added a second test for #278 2017-01-03 23:45:30 +01:00