Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 19228:889807c79384
templater: add indentation arguments to the fill function
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Thu, 18 Apr 2013 15:48:22 -0500 |
parents | 8eef5b93db9d |
children | 867b9957d895 |
line wrap: on
line diff
--- a/mercurial/templater.py Wed Apr 10 18:56:38 2013 -0500 +++ b/mercurial/templater.py Thu Apr 18 15:48:22 2013 -0500 @@ -299,18 +299,29 @@ return minirst.format(text, style=style, keep=['verbose']) def fill(context, mapping, args): - if not (1 <= len(args) <= 2): - raise error.ParseError(_("fill expects one or two arguments")) + if not (1 <= len(args) <= 4): + raise error.ParseError(_("fill expects one to four arguments")) text = stringify(args[0][0](context, mapping, args[0][1])) width = 76 - if len(args) == 2: + initindent = '' + hangindent = '' + if 2 <= len(args) <= 4: try: width = int(stringify(args[1][0](context, mapping, args[1][1]))) except ValueError: raise error.ParseError(_("fill expects an integer width")) + try: + initindent = stringify(args[2][0](context, mapping, args[2][1])) + initindent = stringify(runtemplate(context, mapping, + compiletemplate(initindent, context))) + hangindent = stringify(args[3][0](context, mapping, args[3][1])) + hangindent = stringify(runtemplate(context, mapping, + compiletemplate(hangindent, context))) + except IndexError: + pass - return templatefilters.fill(text, width) + return templatefilters.fill(text, width, initindent, hangindent) def date(context, mapping, args): if not (1 <= len(args) <= 2):