Mercurial > hg-stable
changeset 8234:27dbe534397b
templatefilters: add "nonempty" template filter
It ensures that at least "(none)" is returned in case the argument
passed is None or ''. This is primarily useful to render empty
changelog messages for hgweb but may be useful for others, too.
author | Rocco Rutte <pdmef@gmx.net> |
---|---|
date | Mon, 20 Apr 2009 11:34:15 +0200 |
parents | 655c435efe92 |
children | 89bc3946c8f3 |
files | mercurial/templatefilters.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatefilters.py Mon Apr 27 22:15:36 2009 +0200 +++ b/mercurial/templatefilters.py Mon Apr 20 11:34:15 2009 +0200 @@ -165,6 +165,9 @@ else: return dir +def nonempty(str): + return str or "(none)" + filters = { "addbreaks": nl2br, "basename": os.path.basename, @@ -183,6 +186,7 @@ "isodatesec": lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2'), "json": json, "jsonescape": jsonescape, + "nonempty": nonempty, "obfuscate": obfuscate, "permissions": permissions, "person": person,