templater: strip whitespace inside template methods
authorMatt Mackall <mpm@selenic.com>
Mon, 05 Apr 2010 15:25:08 -0500
changeset 10854 4036634560d6
parent 10853 b6f6d9fd53d6
child 10855 62216faed067
templater: strip whitespace inside template methods
mercurial/templater.py
--- a/mercurial/templater.py	Mon Apr 05 15:25:08 2010 -0500
+++ b/mercurial/templater.py	Mon Apr 05 15:25:08 2010 -0500
@@ -139,17 +139,18 @@
 
             if '%' in expr:
                 key, t = expr.split('%')
-                parsed.append((self._format, (key, self._load(t))))
+                parsed.append((self._format, (key.strip(),
+                                              self._load(t.strip()))))
             elif '|' in expr:
                 parts = expr.split('|')
-                val = parts[0]
+                val = parts[0].strip()
                 try:
-                    filters = [self._filters[f] for f in parts[1:]]
+                    filters = [self._filters[f.strip()] for f in parts[1:]]
                 except KeyError, i:
                     raise SyntaxError(_("unknown filter '%s'") % i[0])
                 parsed.append((self._filter, (filters, val)))
             else:
-                parsed.append((self._get, expr))
+                parsed.append((self._get, expr.strip()))
 
         return parsed