Skip to content
Myr

Fixed groupby bare integer. This fixes #40

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 18286b6 · Browse files · 2 files+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−1 removed

  • other:+8 added−1 removed

2 files+8 added−1 removed

modified:jinja2/testsuite/filters.py+7 added
286 unmodified lines
287 "3: 3, 4",288 ""289 ]290291 def test_groupby_tuple_index(self):292 tmpl = env.from_string('''293 {%- for grouper, list in [('a', 1), ('a', 2), ('b', 1)]|groupby(0) -%}294 {{ grouper }}{% for x in list %}:{{ x.1 }}{% endfor %}|295 {%- endfor %}''')296 assert tmpl.render() == 'a:1:2|b:1|'297298 def test_groupby_multidot(self):299 class Date(object):300 def __init__(self, day, month, year):301 self.day = day
55 unmodified lines
modified:jinja2/filters.py+1 added-1 removed
51 unmodified lines
52 """Returns a callable that looks up the given attribute from a53 passed object with the rules of the environment. Dots are allowed54 to access attributes of attributes.55 """56 if '.' not in attribute:56 if not isinstance(attribute, basestring) or '.' not in attribute:57 return lambda x: environment.getitem(x, attribute)58 attribute = attribute.split('.')59 def attrgetter(item):60 for part in attribute:
741 unmodified lines