##// END OF EJS Templates
templater: make pad() compute actual width...
Yuya Nishihara -
r31520:6f150bb1 default
parent child Browse files
Show More
@@ -14,6 +14,7 b' import types'
14 14 from .i18n import _
15 15 from . import (
16 16 config,
17 encoding,
17 18 error,
18 19 minirst,
19 20 parser,
@@ -581,10 +582,13 b' def pad(context, mapping, args):'
581 582 if len(args) > 3:
582 583 left = evalboolean(context, mapping, args[3])
583 584
585 fillwidth = width - encoding.colwidth(text)
586 if fillwidth <= 0:
587 return text
584 588 if left:
585 return text.rjust(width, fillchar)
589 return fillchar * fillwidth + text
586 590 else:
587 return text.ljust(width, fillchar)
591 return text + fillchar * fillwidth
588 592
589 593 @templatefunc('indent(text, indentchars[, firstline])')
590 594 def indent(context, mapping, args):
@@ -4115,6 +4115,11 b' utf8 filter:'
4115 4115 abort: template filter 'utf8' is not compatible with keyword 'rev'
4116 4116 [255]
4117 4117
4118 pad width:
4119
4120 $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
4121 \xc3\xa9- (esc)
4122
4118 4123 $ cd ..
4119 4124
4120 4125 Test that template function in extension is registered as expected
General Comments 0
You need to be logged in to leave comments. Login now