Show More
@@ -390,6 +390,14 def person(author): | |||||
390 | return stringutil.person(author) |
|
390 | return stringutil.person(author) | |
391 |
|
391 | |||
392 |
|
392 | |||
|
393 | @templatefilter(b'reverse') | |||
|
394 | def reverse(list_): | |||
|
395 | """List. Reverses the order of list items.""" | |||
|
396 | if isinstance(list_, list): | |||
|
397 | return templateutil.hybridlist(list_[::-1], name=b'item') | |||
|
398 | raise error.ParseError(_(b'not reversible')) | |||
|
399 | ||||
|
400 | ||||
393 | @templatefilter(b'revescape', intype=bytes) |
|
401 | @templatefilter(b'revescape', intype=bytes) | |
394 | def revescape(text): |
|
402 | def revescape(text): | |
395 | """Any text. Escapes all "special" characters, except @. |
|
403 | """Any text. Escapes all "special" characters, except @. |
@@ -1718,4 +1718,19 read config options: | |||||
1718 | $ hg log -T "{config('templateconfig', 'knob', if(true, 'foo', 'bar'))}\n" |
|
1718 | $ hg log -T "{config('templateconfig', 'knob', if(true, 'foo', 'bar'))}\n" | |
1719 | foo |
|
1719 | foo | |
1720 |
|
1720 | |||
|
1721 | reverse filter: | |||
|
1722 | ||||
|
1723 | $ hg log -T "{'abc\ndef\nghi'|splitlines|reverse}\n" | |||
|
1724 | ghi def abc | |||
|
1725 | ||||
|
1726 | $ hg log -T "{'abc'|reverse}\n" | |||
|
1727 | hg: parse error: not reversible | |||
|
1728 | (incompatible use of template filter 'reverse') | |||
|
1729 | [10] | |||
|
1730 | ||||
|
1731 | $ hg log -T "{date|reverse}\n" | |||
|
1732 | hg: parse error: not reversible | |||
|
1733 | (template filter 'reverse' is not compatible with keyword 'date') | |||
|
1734 | [10] | |||
|
1735 | ||||
1721 |
$ |
|
1736 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now