349 self._out = out |
349 self._out = out |
350 spec = lookuptemplate(ui, topic, opts.get('template', '')) |
350 spec = lookuptemplate(ui, topic, opts.get('template', '')) |
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', {}) |
358 |
358 |
359 def context(self, **ctxs): |
359 def context(self, **ctxs): |
362 assert all(k == 'ctx' for k in ctxs) |
362 assert all(k == 'ctx' for k in ctxs) |
363 self._item.update(ctxs) |
363 self._item.update(ctxs) |
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): |
371 if part not in self._parts: |
373 if part not in self._parts: |
372 return |
374 return |