##// END OF EJS Templates
templatekw: rename 'args' to 'mapping' in showlist()...
Yuya Nishihara -
r32035:f4ba3345 default
parent child Browse files
Show More
@@ -78,13 +78,13 b' def unwraphybrid(thing):'
78 return thing
78 return thing
79 return thing.gen
79 return thing.gen
80
80
81 def showlist(name, values, plural=None, element=None, separator=' ', **args):
81 def showlist(name, values, plural=None, element=None, separator=' ', **mapping):
82 if not element:
82 if not element:
83 element = name
83 element = name
84 f = _showlist(name, values, plural, separator, **args)
84 f = _showlist(name, values, plural, separator, **mapping)
85 return hybridlist(values, name=element, gen=f)
85 return hybridlist(values, name=element, gen=f)
86
86
87 def _showlist(name, values, plural=None, separator=' ', **args):
87 def _showlist(name, values, plural=None, separator=' ', **mapping):
88 '''expand set of values.
88 '''expand set of values.
89 name is name of key in template map.
89 name is name of key in template map.
90 values is list of strings or dicts.
90 values is list of strings or dicts.
@@ -105,35 +105,35 b' def _showlist(name, values, plural=None,'
105
105
106 expand 'end_foos'.
106 expand 'end_foos'.
107 '''
107 '''
108 templ = args['templ']
108 templ = mapping['templ']
109 if not plural:
109 if not plural:
110 plural = name + 's'
110 plural = name + 's'
111 if not values:
111 if not values:
112 noname = 'no_' + plural
112 noname = 'no_' + plural
113 if noname in templ:
113 if noname in templ:
114 yield templ(noname, **args)
114 yield templ(noname, **mapping)
115 return
115 return
116 if name not in templ:
116 if name not in templ:
117 if isinstance(values[0], str):
117 if isinstance(values[0], str):
118 yield separator.join(values)
118 yield separator.join(values)
119 else:
119 else:
120 for v in values:
120 for v in values:
121 yield dict(v, **args)
121 yield dict(v, **mapping)
122 return
122 return
123 startname = 'start_' + plural
123 startname = 'start_' + plural
124 if startname in templ:
124 if startname in templ:
125 yield templ(startname, **args)
125 yield templ(startname, **mapping)
126 vargs = args.copy()
126 vmapping = mapping.copy()
127 def one(v, tag=name):
127 def one(v, tag=name):
128 try:
128 try:
129 vargs.update(v)
129 vmapping.update(v)
130 except (AttributeError, ValueError):
130 except (AttributeError, ValueError):
131 try:
131 try:
132 for a, b in v:
132 for a, b in v:
133 vargs[a] = b
133 vmapping[a] = b
134 except ValueError:
134 except ValueError:
135 vargs[name] = v
135 vmapping[name] = v
136 return templ(tag, **vargs)
136 return templ(tag, **vmapping)
137 lastname = 'last_' + name
137 lastname = 'last_' + name
138 if lastname in templ:
138 if lastname in templ:
139 last = values.pop()
139 last = values.pop()
@@ -145,7 +145,7 b' def _showlist(name, values, plural=None,'
145 yield one(last, tag=lastname)
145 yield one(last, tag=lastname)
146 endname = 'end_' + plural
146 endname = 'end_' + plural
147 if endname in templ:
147 if endname in templ:
148 yield templ(endname, **args)
148 yield templ(endname, **mapping)
149
149
150 def _formatrevnode(ctx):
150 def _formatrevnode(ctx):
151 """Format changeset as '{rev}:{node|formatnode}', which is the default
151 """Format changeset as '{rev}:{node|formatnode}', which is the default
General Comments 0
You need to be logged in to leave comments. Login now