Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 24566:6abce80e6cbf
templatefilters: add "upper" and "lower" for case conversion
Typically it will be used in patchbomb's flag template, which will be
implemented by future patches.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 30 Mar 2015 23:54:29 +0900 |
parents | a9f826c3eaf9 |
children | c54248bbe023 |
comparison
equal
deleted
inserted
replaced
24565:2f7cb6e6acdd | 24566:6abce80e6cbf |
---|---|
232 | 232 |
233 def localdate(text): | 233 def localdate(text): |
234 """:localdate: Date. Converts a date to local date.""" | 234 """:localdate: Date. Converts a date to local date.""" |
235 return (util.parsedate(text)[0], util.makedate()[1]) | 235 return (util.parsedate(text)[0], util.makedate()[1]) |
236 | 236 |
237 def lower(text): | |
238 """:lower: Any text. Converts the text to lowercase.""" | |
239 return encoding.lower(text) | |
240 | |
237 def nonempty(str): | 241 def nonempty(str): |
238 """:nonempty: Any text. Returns '(none)' if the string is empty.""" | 242 """:nonempty: Any text. Returns '(none)' if the string is empty.""" |
239 return str or "(none)" | 243 return str or "(none)" |
240 | 244 |
241 def obfuscate(text): | 245 def obfuscate(text): |
341 def tabindent(text): | 345 def tabindent(text): |
342 """:tabindent: Any text. Returns the text, with every non-empty line | 346 """:tabindent: Any text. Returns the text, with every non-empty line |
343 except the first starting with a tab character. | 347 except the first starting with a tab character. |
344 """ | 348 """ |
345 return indent(text, '\t') | 349 return indent(text, '\t') |
350 | |
351 def upper(text): | |
352 """:upper: Any text. Converts the text to uppercase.""" | |
353 return encoding.upper(text) | |
346 | 354 |
347 def urlescape(text): | 355 def urlescape(text): |
348 """:urlescape: Any text. Escapes all "special" characters. For example, | 356 """:urlescape: Any text. Escapes all "special" characters. For example, |
349 "foo bar" becomes "foo%20bar". | 357 "foo bar" becomes "foo%20bar". |
350 """ | 358 """ |
385 "isodate": isodate, | 393 "isodate": isodate, |
386 "isodatesec": isodatesec, | 394 "isodatesec": isodatesec, |
387 "json": json, | 395 "json": json, |
388 "jsonescape": jsonescape, | 396 "jsonescape": jsonescape, |
389 "localdate": localdate, | 397 "localdate": localdate, |
398 "lower": lower, | |
390 "nonempty": nonempty, | 399 "nonempty": nonempty, |
391 "obfuscate": obfuscate, | 400 "obfuscate": obfuscate, |
392 "permissions": permissions, | 401 "permissions": permissions, |
393 "person": person, | 402 "person": person, |
394 "rfc3339date": rfc3339date, | 403 "rfc3339date": rfc3339date, |
400 "stringescape": stringescape, | 409 "stringescape": stringescape, |
401 "stringify": stringify, | 410 "stringify": stringify, |
402 "strip": strip, | 411 "strip": strip, |
403 "stripdir": stripdir, | 412 "stripdir": stripdir, |
404 "tabindent": tabindent, | 413 "tabindent": tabindent, |
414 "upper": upper, | |
405 "urlescape": urlescape, | 415 "urlescape": urlescape, |
406 "user": userfilter, | 416 "user": userfilter, |
407 "emailuser": emailuser, | 417 "emailuser": emailuser, |
408 "xmlescape": xmlescape, | 418 "xmlescape": xmlescape, |
409 } | 419 } |