[PATCH 2 of 2] template: add pad function for padding output

Durham Goode durham at fb.com
Fri Jan 17 12:44:36 CST 2014


On 1/17/14 5:41 AM, "Mads Kiilerich" <mads at kiilerich.com> wrote:

>On 01/17/2014 09:45 AM, Durham Goode wrote:
>> # HG changeset patch
>> # User Durham Goode <durham at fb.com>
>> # Date 1389946608 28800
>> #      Fri Jan 17 00:16:48 2014 -0800
>> # Node ID 77cf62dd2af0b5631a2864744e720e61ad4cde6a
>> # Parent  b18359a70b640d2aeb3f4afd1c8e47d775402b8e
>> template: add pad function for padding output
>>
>> Adds a pad template function with the following signature:
>>
>> pad(text, width, right=False, fillchar=' ')
>
>> +    if len(args) > 2:
>> +        right = stringify(args[2][0](context, mapping, args[2][1])) ==
>>"True"
>
>Expecting a literal "True" would surprise me as a user. Most other
>boolean inputs use util.parsebool.

Will fix

>
>But I think I would suggest having a separate 'rpad' "filter" instead.
>

The problem with rpad is that it's ambiguous (Does the padding go on the
right? Does the text go on the right?). I'd have to use rjustify and
ljustify, like python does, but when I am looking for functions like this
I search for the word 'pad'.  I think right justified output will be rare
enough that it's ok regulating it to an optional parameter.



More information about the Mercurial-devel mailing list