Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 17639:d42cc3c880b6
templatefilters: add parameterized date method
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 24 Sep 2012 15:54:45 -0500 |
parents | e2711975be00 |
children | bededd3f0735 |
comparison
equal
deleted
inserted
replaced
17638:e2711975be00 | 17639:d42cc3c880b6 |
---|---|
403 except ValueError: | 403 except ValueError: |
404 raise error.ParseError(_("fill expects an integer width")) | 404 raise error.ParseError(_("fill expects an integer width")) |
405 | 405 |
406 return fill(text, width) | 406 return fill(text, width) |
407 | 407 |
408 def datefunc(context, mapping, args): | |
409 if not (1 <= len(args) <= 2): | |
410 raise error.ParseError(_("date expects one or two arguments")) | |
411 | |
412 date = args[0][0](context, mapping, args[0][1]) | |
413 if len(args) == 2: | |
414 fmt = stringify(args[1][0](context, mapping, args[1][1])) | |
415 return util.datestr(date, fmt) | |
416 return util.datestr(date) | |
408 | 417 |
409 funcs = { | 418 funcs = { |
410 "fill": fillfunc, | 419 "fill": fillfunc, |
420 "date": datefunc, | |
411 } | 421 } |
412 | 422 |
413 # tell hggettext to extract docstrings from these functions: | 423 # tell hggettext to extract docstrings from these functions: |
414 i18nfunctions = filters.values() | 424 i18nfunctions = filters.values() |