equal
deleted
inserted
replaced
502 except IndexError: |
502 except IndexError: |
503 pass |
503 pass |
504 |
504 |
505 return templatefilters.fill(text, width, initindent, hangindent) |
505 return templatefilters.fill(text, width, initindent, hangindent) |
506 |
506 |
507 @templatefunc('pad(text, width[, fillchar=\' \'[, right=False]])') |
507 @templatefunc('pad(text, width[, fillchar=\' \'[, left=False]])') |
508 def pad(context, mapping, args): |
508 def pad(context, mapping, args): |
509 """Pad text with a |
509 """Pad text with a |
510 fill character.""" |
510 fill character.""" |
511 if not (2 <= len(args) <= 4): |
511 if not (2 <= len(args) <= 4): |
512 # i18n: "pad" is a keyword |
512 # i18n: "pad" is a keyword |
516 # i18n: "pad" is a keyword |
516 # i18n: "pad" is a keyword |
517 _("pad() expects an integer width")) |
517 _("pad() expects an integer width")) |
518 |
518 |
519 text = evalstring(context, mapping, args[0]) |
519 text = evalstring(context, mapping, args[0]) |
520 |
520 |
521 right = False |
521 left = False |
522 fillchar = ' ' |
522 fillchar = ' ' |
523 if len(args) > 2: |
523 if len(args) > 2: |
524 fillchar = evalstring(context, mapping, args[2]) |
524 fillchar = evalstring(context, mapping, args[2]) |
525 if len(args) > 3: |
525 if len(args) > 3: |
526 right = evalboolean(context, mapping, args[3]) |
526 left = evalboolean(context, mapping, args[3]) |
527 |
527 |
528 if right: |
528 if left: |
529 return text.rjust(width, fillchar) |
529 return text.rjust(width, fillchar) |
530 else: |
530 else: |
531 return text.ljust(width, fillchar) |
531 return text.ljust(width, fillchar) |
532 |
532 |
533 @templatefunc('indent(text, indentchars[, firstline])') |
533 @templatefunc('indent(text, indentchars[, firstline])') |