templater: add no-op template function 'label'
authorSean Farley <sean.michael.farley@gmail.com>
Sat, 22 Dec 2012 21:46:26 -0600
changeset 18289 9bfb53106328
parent 18288 0d5a22f73a1f
child 18290 323e1267de36
templater: add no-op template function 'label'
mercurial/templater.py
--- a/mercurial/templater.py	Wed Jan 09 20:27:17 2013 +0100
+++ b/mercurial/templater.py	Sat Dec 22 21:46:26 2012 -0600
@@ -265,6 +265,15 @@
         t = stringify(args[3][0](context, mapping, args[3][1]))
         yield runtemplate(context, mapping, compiletemplate(t, context))
 
+def label(context, mapping, args):
+    if len(args) != 2:
+        # i18n: "label" is a keyword
+        raise error.ParseError(_("label expects two arguments"))
+
+    # ignore args[0] (the label string) since this is supposed to be a a no-op
+    t = stringify(args[1][0](context, mapping, args[1][1]))
+    yield runtemplate(context, mapping, compiletemplate(t, context))
+
 methods = {
     "string": lambda e, c: (runstring, e[1]),
     "symbol": lambda e, c: (runsymbol, e[1]),
@@ -280,6 +289,7 @@
     "ifeq": ifeq,
     "join": join,
     "sub": sub,
+    "label": label,
 }
 
 # template engine