diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2016-12-29 11:38:28 +0100 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2016-12-29 11:38:43 +0100 |
commit | a6e48b42635ec40b413ea35e2fb30d37fc4fe503 (patch) | |
tree | bce3db191c86f9db503ad5622c3873e6d4279dc4 /jinja2 | |
parent | 2b03052c9b6f7028e5cb79fb96440a0560bc4340 (diff) | |
download | jinja2-feature/async.tar.gz |
Make slice work with async generatorsfeature/async
Diffstat (limited to 'jinja2')
-rw-r--r-- | jinja2/asyncfilters.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/jinja2/asyncfilters.py b/jinja2/asyncfilters.py index 26caccb..d12afaf 100644 --- a/jinja2/asyncfilters.py +++ b/jinja2/asyncfilters.py @@ -122,6 +122,11 @@ async def do_sum(environment, iterable, attribute=None, start=0): return rv +@asyncfiltervariant(filters.do_slice) +async def do_slice(value, slices, fill_with=None): + return filters.do_slice(await auto_to_seq(value), slices, fill_with) + + ASYNC_FILTERS = { 'first': do_first, 'groupby': do_groupby, @@ -135,4 +140,5 @@ ASYNC_FILTERS = { 'select': do_select, 'selectattr': do_selectattr, 'sum': do_sum, + 'slice': do_slice, } |