Show More
@@ -195,6 +195,26 b' def buildfunc(exp, context):' | |||||
195 | f = context._filters[n] |
|
195 | f = context._filters[n] | |
196 | return (runfilter, (args[0][0], args[0][1], f)) |
|
196 | return (runfilter, (args[0][0], args[0][1], f)) | |
197 |
|
197 | |||
|
198 | def join(context, mapping, args): | |||
|
199 | if not (1 <= len(args) <= 2): | |||
|
200 | raise error.ParseError(_("join expects one or two arguments")) | |||
|
201 | ||||
|
202 | joinset = args[0][0](context, mapping, args[0][1]) | |||
|
203 | if util.safehasattr(joinset, '__call__'): | |||
|
204 | joinset = [x.values()[0] for x in joinset()] | |||
|
205 | ||||
|
206 | joiner = " " | |||
|
207 | if len(args) > 1: | |||
|
208 | joiner = args[1][0](context, mapping, args[1][1]) | |||
|
209 | ||||
|
210 | first = True | |||
|
211 | for x in joinset: | |||
|
212 | if first: | |||
|
213 | first = False | |||
|
214 | else: | |||
|
215 | yield joiner | |||
|
216 | yield x | |||
|
217 | ||||
198 | methods = { |
|
218 | methods = { | |
199 | "string": lambda e, c: (runstring, e[1]), |
|
219 | "string": lambda e, c: (runstring, e[1]), | |
200 | "symbol": lambda e, c: (runsymbol, e[1]), |
|
220 | "symbol": lambda e, c: (runsymbol, e[1]), | |
@@ -206,6 +226,7 b' methods = {' | |||||
206 | } |
|
226 | } | |
207 |
|
227 | |||
208 | funcs = { |
|
228 | funcs = { | |
|
229 | "join": join, | |||
209 | } |
|
230 | } | |
210 |
|
231 | |||
211 | # template engine |
|
232 | # template engine |
General Comments 0
You need to be logged in to leave comments.
Login now