##// END OF EJS Templates
templater: allow piping generator-type function output to filters...
Yuya Nishihara -
r24280:6c55e37b default
parent child Browse files
Show More
@@ -162,8 +162,13 b' def buildfilter(exp, context):'
162
162
163 def runfilter(context, mapping, data):
163 def runfilter(context, mapping, data):
164 func, data, filt = data
164 func, data, filt = data
165 # func() may return string, generator of strings or arbitrary object such
166 # as date tuple, but filter does not want generator.
167 thing = func(context, mapping, data)
168 if isinstance(thing, types.GeneratorType):
169 thing = stringify(thing)
165 try:
170 try:
166 return filt(func(context, mapping, data))
171 return filt(thing)
167 except (ValueError, AttributeError, TypeError):
172 except (ValueError, AttributeError, TypeError):
168 if isinstance(data, tuple):
173 if isinstance(data, tuple):
169 dt = data[1]
174 dt = data[1]
@@ -1901,6 +1901,11 b' Thrown an error if a template function d'
1901 hg: parse error: unknown function 'foo'
1901 hg: parse error: unknown function 'foo'
1902 [255]
1902 [255]
1903
1903
1904 Pass generator object created by template function to filter
1905
1906 $ hg log -l 1 --template '{if(author, author)|user}\n'
1907 test
1908
1904 Test diff function:
1909 Test diff function:
1905
1910
1906 $ hg diff -c 8
1911 $ hg diff -c 8
General Comments 0
You need to be logged in to leave comments. Login now