comparison mercurial/templater.py @ 26106:c568c4db036f

templatefilters: remove redundant 'date' and 'strip' filters These filters are defined as 'date()' and 'strip()' functions. Help messages are moved to the corresponding functions.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 04 Jul 2015 16:07:42 +0900
parents d67341f55429
children 604a7c941103
comparison
equal deleted inserted replaced
26105:d67341f55429 26106:c568c4db036f
311 return (runfilter, (args[0][0], args[0][1], f)) 311 return (runfilter, (args[0][0], args[0][1], f))
312 raise error.ParseError(_("unknown function '%s'") % n) 312 raise error.ParseError(_("unknown function '%s'") % n)
313 313
314 def date(context, mapping, args): 314 def date(context, mapping, args):
315 """:date(date[, fmt]): Format a date. See :hg:`help dates` for formatting 315 """:date(date[, fmt]): Format a date. See :hg:`help dates` for formatting
316 strings.""" 316 strings. The default is a Unix date format, including the timezone:
317 "Mon Sep 04 15:13:13 2006 0700"."""
317 if not (1 <= len(args) <= 2): 318 if not (1 <= len(args) <= 2):
318 # i18n: "date" is a keyword 319 # i18n: "date" is a keyword
319 raise error.ParseError(_("date expects one or two arguments")) 320 raise error.ParseError(_("date expects one or two arguments"))
320 321
321 date = args[0][0](context, mapping, args[0][1]) 322 date = args[0][0](context, mapping, args[0][1])
602 length += 1 603 length += 1
603 if len(shortest) <= length: 604 if len(shortest) <= length:
604 return shortest 605 return shortest
605 606
606 def strip(context, mapping, args): 607 def strip(context, mapping, args):
607 """:strip(text[, chars]): Strip characters from a string.""" 608 """:strip(text[, chars]): Strip characters from a string. By default,
609 strips all leading and trailing whitespace."""
608 if not (1 <= len(args) <= 2): 610 if not (1 <= len(args) <= 2):
609 # i18n: "strip" is a keyword 611 # i18n: "strip" is a keyword
610 raise error.ParseError(_("strip expects one or two arguments")) 612 raise error.ParseError(_("strip expects one or two arguments"))
611 613
612 text = stringify(args[0][0](context, mapping, args[0][1])) 614 text = stringify(args[0][0](context, mapping, args[0][1]))