243 except IndexError: |
243 except IndexError: |
244 pass |
244 pass |
245 |
245 |
246 return templatefilters.fill(text, width, initindent, hangindent) |
246 return templatefilters.fill(text, width, initindent, hangindent) |
247 |
247 |
|
248 def pad(context, mapping, args): |
|
249 """usage: pad(text, width, fillchar=' ', right=False) |
|
250 """ |
|
251 if not (2 <= len(args) <= 4): |
|
252 raise error.ParseError(_("pad() expects two to four arguments")) |
|
253 |
|
254 width = int(args[1][1]) |
|
255 |
|
256 text = stringify(args[0][0](context, mapping, args[0][1])) |
|
257 if args[0][0] == runstring: |
|
258 text = stringify(runtemplate(context, mapping, |
|
259 compiletemplate(text, context))) |
|
260 |
|
261 right = False |
|
262 fillchar = ' ' |
|
263 if len(args) > 2: |
|
264 fillchar = stringify(args[2][0](context, mapping, args[2][1])) |
|
265 if len(args) > 3: |
|
266 right = util.parsebool(args[3][1]) |
|
267 |
|
268 if right: |
|
269 return text.rjust(width, fillchar) |
|
270 else: |
|
271 return text.ljust(width, fillchar) |
|
272 |
248 def get(context, mapping, args): |
273 def get(context, mapping, args): |
249 if len(args) != 2: |
274 if len(args) != 2: |
250 # i18n: "get" is a keyword |
275 # i18n: "get" is a keyword |
251 raise error.ParseError(_("get() expects two arguments")) |
276 raise error.ParseError(_("get() expects two arguments")) |
252 |
277 |