Show More
@@ -6,7 +6,7 b'' | |||||
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | import sys, os |
|
9 | import sys, os, re | |
10 | import util, config, templatefilters, parser, error |
|
10 | import util, config, templatefilters, parser, error | |
11 |
|
11 | |||
12 | # template parsing |
|
12 | # template parsing | |
@@ -218,6 +218,15 b' def join(context, mapping, args):' | |||||
218 | yield joiner |
|
218 | yield joiner | |
219 | yield x |
|
219 | yield x | |
220 |
|
220 | |||
|
221 | def sub(context, mapping, args): | |||
|
222 | if len(args) != 3: | |||
|
223 | raise error.ParseError(_("sub expects three arguments")) | |||
|
224 | ||||
|
225 | pat = stringify(args[0][0](context, mapping, args[0][1])) | |||
|
226 | rpl = stringify(args[1][0](context, mapping, args[1][1])) | |||
|
227 | src = stringify(args[2][0](context, mapping, args[2][1])) | |||
|
228 | yield re.sub(pat, rpl, src) | |||
|
229 | ||||
221 | methods = { |
|
230 | methods = { | |
222 | "string": lambda e, c: (runstring, e[1]), |
|
231 | "string": lambda e, c: (runstring, e[1]), | |
223 | "symbol": lambda e, c: (runsymbol, e[1]), |
|
232 | "symbol": lambda e, c: (runsymbol, e[1]), | |
@@ -230,6 +239,7 b' methods = {' | |||||
230 |
|
239 | |||
231 | funcs = { |
|
240 | funcs = { | |
232 | "join": join, |
|
241 | "join": join, | |
|
242 | "sub": sub, | |||
233 | } |
|
243 | } | |
234 |
|
244 | |||
235 | # template engine |
|
245 | # template engine |
General Comments 0
You need to be logged in to leave comments.
Login now