diff mercurial/templatefilters.py @ 16360:e5788269741a

templates/filters: extracting the user portion of an email address Currently, the 'user' filter is using util.shortuser(text) (which clearly doesn't extract only the user portion of an email address, even though the help text says it does). The new 'emailuser' filter uses the new util.emailuser(text) function which, instead, does exactly that. The help text on the 'user' filter has been modified accordingly.
author Matteo Capobianco <m.capobianco@gmail.com>
date Wed, 28 Mar 2012 16:06:20 +0200
parents db68ee3289b6
children 67964cda8701
line wrap: on
line diff
--- a/mercurial/templatefilters.py	Thu Apr 05 19:23:04 2012 +0200
+++ b/mercurial/templatefilters.py	Wed Mar 28 16:06:20 2012 +0200
@@ -336,9 +336,14 @@
     return urllib.quote(text)
 
 def userfilter(text):
-    """:user: Any text. Returns the user portion of an email address."""
+    """:user: Any text. Returns a short representation of a user name or email
+    address."""
     return util.shortuser(text)
 
+def emailuser(text):
+    """:emailuser: Any text. Returns the user portion of an email address."""
+    return util.emailuser(text)
+
 def xmlescape(text):
     text = (text
             .replace('&', '&amp;')
@@ -382,6 +387,7 @@
     "tabindent": tabindent,
     "urlescape": urlescape,
     "user": userfilter,
+    "emailuser": emailuser,
     "xmlescape": xmlescape,
 }