Show More
@@ -215,6 +215,15 b' def gettemplate(exp, context):' | |||||
215 | return context._load(exp[1]) |
|
215 | return context._load(exp[1]) | |
216 | raise error.ParseError(_("expected template specifier")) |
|
216 | raise error.ParseError(_("expected template specifier")) | |
217 |
|
217 | |||
|
218 | def evalfuncarg(context, mapping, arg): | |||
|
219 | func, data = arg | |||
|
220 | # func() may return string, generator of strings or arbitrary object such | |||
|
221 | # as date tuple, but filter does not want generator. | |||
|
222 | thing = func(context, mapping, data) | |||
|
223 | if isinstance(thing, types.GeneratorType): | |||
|
224 | thing = stringify(thing) | |||
|
225 | return thing | |||
|
226 | ||||
218 | def runinteger(context, mapping, data): |
|
227 | def runinteger(context, mapping, data): | |
219 | return int(data) |
|
228 | return int(data) | |
220 |
|
229 | |||
@@ -259,11 +268,7 b' def buildfilter(exp, context):' | |||||
259 |
|
268 | |||
260 | def runfilter(context, mapping, data): |
|
269 | def runfilter(context, mapping, data): | |
261 | func, data, filt = data |
|
270 | func, data, filt = data | |
262 | # func() may return string, generator of strings or arbitrary object such |
|
271 | thing = evalfuncarg(context, mapping, (func, data)) | |
263 | # as date tuple, but filter does not want generator. |
|
|||
264 | thing = func(context, mapping, data) |
|
|||
265 | if isinstance(thing, types.GeneratorType): |
|
|||
266 | thing = stringify(thing) |
|
|||
267 | try: |
|
272 | try: | |
268 | return filt(thing) |
|
273 | return filt(thing) | |
269 | except (ValueError, AttributeError, TypeError): |
|
274 | except (ValueError, AttributeError, TypeError): |
General Comments 0
You need to be logged in to leave comments.
Login now