##// END OF EJS Templates
formatter: add support for separator template...
Yuya Nishihara -
r32950:5100ce21 default
parent child Browse files
Show More
@@ -351,7 +351,7 b' class templateformatter(baseformatter):'
351 self._tref = spec.ref
351 self._tref = spec.ref
352 self._t = loadtemplater(ui, spec, cache=templatekw.defaulttempl)
352 self._t = loadtemplater(ui, spec, cache=templatekw.defaulttempl)
353 self._parts = templatepartsmap(spec, self._t,
353 self._parts = templatepartsmap(spec, self._t,
354 ['docheader', 'docfooter'])
354 ['docheader', 'docfooter', 'separator'])
355 self._counter = itertools.count()
355 self._counter = itertools.count()
356 self._cache = {} # for templatekw/funcs to store reusable data
356 self._cache = {} # for templatekw/funcs to store reusable data
357 self._renderitem('docheader', {})
357 self._renderitem('docheader', {})
@@ -364,7 +364,9 b' class templateformatter(baseformatter):'
364
364
365 def _showitem(self):
365 def _showitem(self):
366 item = self._item.copy()
366 item = self._item.copy()
367 item['index'] = next(self._counter)
367 item['index'] = index = next(self._counter)
368 if index > 0:
369 self._renderitem('separator', {})
368 self._renderitem(self._tref, item)
370 self._renderitem(self._tref, item)
369
371
370 def _renderitem(self, part, item):
372 def _renderitem(self, part, item):
@@ -533,7 +533,8 b' template output:'
533 $ cat <<'EOF' > "$TESTTMP/map-myjson"
533 $ cat <<'EOF' > "$TESTTMP/map-myjson"
534 > docheader = '\{\n'
534 > docheader = '\{\n'
535 > docfooter = '\n}\n'
535 > docfooter = '\n}\n'
536 > branches = '{ifeq(index, 0, "", ",\n")} {dict(branch, node|short)|json}'
536 > separator = ',\n'
537 > branches = ' {dict(branch, node|short)|json}'
537 > EOF
538 > EOF
538 $ hg branches -T "$TESTTMP/map-myjson"
539 $ hg branches -T "$TESTTMP/map-myjson"
539 {
540 {
General Comments 0
You need to be logged in to leave comments. Login now