##// END OF EJS Templates
templatefilters: add parameterized fill function
Matt Mackall -
r17638:e2711975 default
parent child Browse files
Show More
@@ -6,7 +6,7
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import cgi, re, os, time, urllib
8 import cgi, re, os, time, urllib
9 import encoding, node, util
9 import encoding, node, util, error
10 import hbisect
10 import hbisect
11
11
12 def addbreaks(text):
12 def addbreaks(text):
@@ -391,5 +391,24 filters = {
391 "xmlescape": xmlescape,
391 "xmlescape": xmlescape,
392 }
392 }
393
393
394 def fillfunc(context, mapping, args):
395 if not (1 <= len(args) <= 2):
396 raise error.ParseError(_("fill expects one or two arguments"))
397
398 text = stringify(args[0][0](context, mapping, args[0][1]))
399 width = 76
400 if len(args) == 2:
401 try:
402 width = int(stringify(args[1][0](context, mapping, args[1][1])))
403 except ValueError:
404 raise error.ParseError(_("fill expects an integer width"))
405
406 return fill(text, width)
407
408
409 funcs = {
410 "fill": fillfunc,
411 }
412
394 # tell hggettext to extract docstrings from these functions:
413 # tell hggettext to extract docstrings from these functions:
395 i18nfunctions = filters.values()
414 i18nfunctions = filters.values()
General Comments 0
You need to be logged in to leave comments. Login now