[PATCH 1 of 6 RFC] templater: add no-op template function 'label'
Sean Farley
sean.michael.farley at gmail.com
Mon Dec 24 01:03:08 CST 2012
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1356234386 21600
# Node ID 54276c120146e14cc4ab931b799c94bd671ee524
# Parent f8a13f061a8a4a278c7029c2cac7417dbcb08808
templater: add no-op template function 'label'
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -263,10 +263,18 @@
yield runtemplate(context, mapping, compiletemplate(t, context))
elif len(args) == 4:
t = stringify(args[3][0](context, mapping, args[3][1]))
yield runtemplate(context, mapping, compiletemplate(t, context))
+def label(context, mapping, args):
+ if not (1 <= len(args) <= 2):
+ # i18n: "label" is a keyword
+ raise error.ParseError(_("label expects one or two arguments"))
+
+ # ignore args[1] (the label string) since this is supposed to be a a no-op
+ yield args[0][0](context, mapping, args[0][1])
+
methods = {
"string": lambda e, c: (runstring, e[1]),
"symbol": lambda e, c: (runsymbol, e[1]),
"group": lambda e, c: compileexp(e[1], c),
# ".": buildmember,
@@ -278,10 +286,11 @@
funcs = {
"if": if_,
"ifeq": ifeq,
"join": join,
"sub": sub,
+ "label": label,
}
# template engine
path = ['templates', '../templates']
More information about the Mercurial-devel
mailing list