Skip to content
Snippets Groups Projects
Commit b4630e33 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

templater: drop unneeded generator from mappable object

Per the definition of the show() interface, it can return a bytes.
parent 8c84dc82
No related branches found
No related tags found
No related merge requests found
......@@ -113,9 +113,8 @@
"""
def __init__(self, gen, key, value, makemap):
if gen is not None:
self._gen = gen # generator or function returning generator
self._gen = gen # generator or function returning generator
self._key = key
self._value = value # may be generator of strings
self._makemap = makemap
......@@ -118,10 +117,7 @@
self._key = key
self._value = value # may be generator of strings
self._makemap = makemap
def _gen(self):
yield pycompat.bytestr(self._value)
def tomap(self):
return self._makemap(self._key)
......@@ -131,6 +127,8 @@
def show(self, context, mapping):
# TODO: switch gen to (context, mapping) API?
gen = self._gen
if gen is None:
return pycompat.bytestr(self._value)
if callable(gen):
return gen()
return gen
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment