Commit Graph

146 Commits

Author SHA1 Message Date
David Lord
e01e0a21f9
Merge pull request #1509 from kianmeng/fix-typos
Fix typos
2021-11-09 09:17:51 -08:00
Kristian Klette
9b96b4817a
Use object.__hash__ for Node.__hash__
This fixes a regression in commit 60293416db that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: https://github.com/django-compressor/django-compressor/issues/1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
2021-11-09 09:12:22 -08:00
Mohamed Akram
b756b1924a
Reduce async overhead due to auto_await 2021-11-09 08:52:20 -08:00
Martin Krizek
bb0db82b91
native: keep same behavior on Python 3.10 2021-11-09 08:41:02 -08:00
David Lord
99435a4e69
simplify CodeType rewriting 2021-11-09 07:10:53 -08:00
Kian-Meng, Ang
8cc3a64fa6 Fix typos 2021-10-12 22:36:44 +08:00
David Lord
76c9cf832a
release version 3.0.2 2021-10-04 17:48:23 -07:00
David Lord
8931077058
omit curdir from PackageLoader root path
fixes compatibility with zip imports

Co-authored-by: kuepe-sl <peter_kueffner@web.de>
2021-10-04 17:39:39 -07:00
Daniel Stone
baff54fe1d
imported macros can access template globals in async mode 2021-10-04 13:49:13 -07:00
Joachim Jablon
d5f49f5cc1
Fixes #1448: Revert Undefined.__contains__ to 2.x behaviour 2021-08-09 11:07:35 -07:00
Takuto Ikuta
4c703ec44d
make compile_templates deterministic
Python3 doesn't keep insertion order for set(), so this sorts some
places for deterministic output for compiled template.
2021-08-09 10:58:24 -07:00
Amy
f3bc9c6a91
clear assignments in loops at end of iteration 2021-05-21 11:24:04 -07:00
David Lord
738644d816
start version 3.0.2.dev0 2021-05-18 13:39:52 -07:00
David Lord
4d23bfb317
release version 3.0.1 2021-05-18 13:35:09 -07:00
David Lord
7d0b7accff
use asyncio.run 2021-05-18 13:22:46 -07:00
David Lord
f562a4fdea
fix deprecated Markup subclass 2021-05-17 06:41:42 -07:00
David Lord
b4d31e7b8d
show context for deprecated extensions 2021-05-13 17:48:19 -07:00
David Lord
9f34d2ac87
fix typing that wasn't available in Python 3.6.0 2021-05-13 17:25:08 -07:00
David Lord
db5fb7971f
mark top-level names as exported 2021-05-13 17:19:23 -07:00
David Lord
e2f673e604
update markupsafe minimum version 2021-05-11 14:21:06 -07:00
David Lord
058c06f24d
start version 3.0.1.dev0 2021-05-11 14:10:02 -07:00
David Lord
b15fd1c94c
release version 3.0.0 2021-05-11 14:02:01 -07:00
David Lord
be15556dba
add type annotations 2021-05-08 13:03:15 -07:00
David Lord
912e59d51f
deprecate legacy resolve mode 2021-04-11 23:53:59 -07:00
David Lord
1932ce3dc4
async support doesn't require patching 2021-04-10 16:12:25 -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
lisongmin
34fbec9a72
add default parameter to groupby 2021-04-05 14:42:34 -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
remidebette
3642ae7fef
NativeEnvironment supports async mode 2021-04-05 11:36:54 -07:00
Jafnee
3242428c52
add Undefined.__aiter__ 2021-04-05 10:51:29 -07:00
David Parker
609bcb0831
Undefined.__contains__ raises UndefinedError 2021-04-05 10:44:31 -07:00
Alex Mykyta
2e0a3da2bc
parse hex, octal, and binary integer literals 2021-04-05 10:35:57 -07:00
Lars Kollstedt
8016b5f139
filters.py: do_indent: ident filter can indent with arbitrary characters
Allow indention with generic characters, e.g. Tabs.

Implemenented the behavior requested in
https://github.com/pallets/jinja/pull/1167#issuecomment-612644701

The width param can be string or int, if it is string it's the raw
indention e.g. "\t". If it's int it's the number of spaces. In other
cases an FilterArgumentError is raised, to avoid confusion.
2021-04-05 09:50:45 -07:00
Sardorbek Imomaliev
3fba898098
add pgettext and npgettext 2021-04-05 04:45:05 -07:00
David Lord
6c733602ac
add 'is filter' and 'is test' tests
This required allowing tests to be decorated with '@environmentfilter'.
Tests are essentially the same as filters now, the node, compiler, and
environment have been refactored to extract common behavior.
2021-04-04 17:20:23 -07:00
Amy
ebf0e2dfda allow optional use of filter based on existence 2021-04-04 13:09:31 -04: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
BALaka-18
73a94e00d4
map filter can use False as default 2021-02-24 17:16:01 -08:00
David Lord
076d380361
Merge branch '2.11.x' 2021-01-31 08:48:44 -08:00
David Lord
cf215390d4
release version 2.11.3 2021-01-31 08:44:37 -08:00
David Lord
ef658dc3b6
speed up urlize matching 2021-01-31 08:02:04 -08:00
David Lord
1aa979c545
refactor urlize function
don't try other url types if one already matched
no-op function if trim is not enabled
avoid backtracking when matching trailing punctuation
match head and tail punctuation separately
don't scan for unbalanced parentheses more than necessary
ensure email domain starts and ends with a word character
2021-01-30 22:20:17 -08:00
David Lord
be83e7e06c
update urlize docs, clean up code
move regexes near implementation
commented verbose regex for http pattern
renamed extra_uri_schemes to extra_schemes
2021-01-30 13:38:56 -08:00
David Lord
c3b34a06f3
update docs about required blocks (#1340) 2021-01-30 05:47:23 -08:00
FawziyahAlebiosu
1843d6d411 deprecate 'with' and 'autoescape' extensions 2021-01-29 16:56:47 -05:00
Amy
8da77f9753 add required attribute to blocks
required blocks must be overridden at some point, although not
necessarily by the direct child template
2021-01-29 10:28:39 -05:00
Martin Krizek
bd8bad37d1 native_concat: pass only strings to literal_eval
If there is only single node and it is not a string, there is no point
in passing it into ``literal_eval``, just return it immediately.

One of the examples where passing a non-string node into
``literal_eval`` would actually cause problems is when the node is
``Undefined``. On Python 3.10 this would cause ``UndefinedError``
instead of just ``Undefined`` being returned.

Fixes #1335
2021-01-28 12:13:30 +01:00
Richard Gibson
e1d0131a7f
detect custom async filters in as_const 2020-10-31 19:07:26 -07:00