| Trees | Indices | Help |
|
|---|
|
|
| Classes | |
|
Paginator Pagination controller |
|
| Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| Function Details |
Helper function for dynamically assembling a list of CSS class names in templates. Any positional arguments are added to the list of class names. All positional arguments must be strings: >>> classes('foo', 'bar') u'foo bar' In addition, the names of any supplied keyword arguments are added if they have a truth value: >>> classes('foo', bar=True) u'foo bar' >>> classes('foo', bar=False) u'foo' If none of the arguments are added to the list, this function
returns >>> classes(bar=False) u'' |
Generate first or last or both, according to the
position In Jinja2 templates, rather use: <li ${{'class': {'first': loop.first, 'last': loop.last}}|htmlattr}> This is less error prone, as the sequence remains implicit and therefore can't be wrong. |
Combines the elements produced by the given iterable so that every >>> items = [1, 2, 3, 4] >>> for item in group(items, 2): ... print(item) (1, 2) (3, 4) The last tuple is padded with >>> items = [1, 2, 3, 4, 5] >>> for item in group(items, 2): ... print(item) (1, 2) (3, 4) (5, None) The optional >>> items = [1, 2, 3, 4] >>> for item in group(items, 2, lambda x: x != 3): ... print(item) (1, 2) (3,) (4, None) |
Simple generic pagination.
The >>> items = list(xrange(12)) >>> items [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] >>> paginate(items) ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 12, 2) >>> paginate(items, page=1) ([10, 11], 12, 2) >>> paginate(iter(items)) ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 12, 2) >>> paginate(iter(items), page=1) ([10, 11], 12, 2) This function also works with generators: >>> def generate(): ... for idx in xrange(12): ... yield idx >>> paginate(generate()) ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 12, 2) >>> paginate(generate(), page=1) ([10, 11], 12, 2) The >>> items = xrange(12) >>> paginate(items, page=0, max_per_page=6) ([0, 1, 2, 3, 4, 5], 12, 2) >>> paginate(items, page=1, max_per_page=6) ([6, 7, 8, 9, 10, 11], 12, 2)
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Mar 30 08:24:26 2020 | http://epydoc.sourceforge.net |