Show More
@@ -148,6 +148,17 def compatdict(context, mapping, name, d | |||||
148 | f = _showlist(name, c, t, mapping, plural, separator) |
|
148 | f = _showlist(name, c, t, mapping, plural, separator) | |
149 | return hybriddict(data, key=key, value=value, fmt=fmt, gen=f) |
|
149 | return hybriddict(data, key=key, value=value, fmt=fmt, gen=f) | |
150 |
|
150 | |||
|
151 | def compatlist(context, mapping, name, data, element=None, fmt='%s', | |||
|
152 | plural=None, separator=' '): | |||
|
153 | """Wrap data like hybridlist(), but also supports old-style list template | |||
|
154 | ||||
|
155 | This exists for backward compatibility with the old-style template. Use | |||
|
156 | hybridlist() for new template keywords. | |||
|
157 | """ | |||
|
158 | t = context.resource(mapping, 'templ') | |||
|
159 | f = _showlist(name, data, t, mapping, plural, separator) | |||
|
160 | return hybridlist(data, name=element or name, fmt=fmt, gen=f) | |||
|
161 | ||||
151 | def showdict(name, data, mapping, plural=None, key='key', value='value', |
|
162 | def showdict(name, data, mapping, plural=None, key='key', value='value', | |
152 | fmt='%s=%s', separator=' '): |
|
163 | fmt='%s=%s', separator=' '): | |
153 | c = [{key: k, value: v} for k, v in data.iteritems()] |
|
164 | c = [{key: k, value: v} for k, v in data.iteritems()] | |
@@ -397,13 +408,12 def showbookmarks(**args): | |||||
397 | f = _showlist('bookmark', bookmarks, args['templ'], args) |
|
408 | f = _showlist('bookmark', bookmarks, args['templ'], args) | |
398 | return _hybrid(f, bookmarks, makemap, pycompat.identity) |
|
409 | return _hybrid(f, bookmarks, makemap, pycompat.identity) | |
399 |
|
410 | |||
400 | @templatekeyword('children') |
|
411 | @templatekeyword('children', requires={'ctx', 'templ'}) | |
401 |
def showchildren( |
|
412 | def showchildren(context, mapping): | |
402 | """List of strings. The children of the changeset.""" |
|
413 | """List of strings. The children of the changeset.""" | |
403 | args = pycompat.byteskwargs(args) |
|
414 | ctx = context.resource(mapping, 'ctx') | |
404 | ctx = args['ctx'] |
|
|||
405 | childrevs = ['%d:%s' % (cctx.rev(), cctx) for cctx in ctx.children()] |
|
415 | childrevs = ['%d:%s' % (cctx.rev(), cctx) for cctx in ctx.children()] | |
406 |
return |
|
416 | return compatlist(context, mapping, 'children', childrevs, element='child') | |
407 |
|
417 | |||
408 | # Deprecated, but kept alive for help generation a purpose. |
|
418 | # Deprecated, but kept alive for help generation a purpose. | |
409 | @templatekeyword('currentbookmark', requires={'repo', 'ctx'}) |
|
419 | @templatekeyword('currentbookmark', requires={'repo', 'ctx'}) |
General Comments 0
You need to be logged in to leave comments.
Login now