Show More
@@ -6,7 +6,7 b'' | |||
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 | import sys, os | |
|
9 | import sys, os, re | |
|
10 | 10 | import util, config, templatefilters, parser, error |
|
11 | 11 | |
|
12 | 12 | # template parsing |
@@ -218,6 +218,15 b' def join(context, mapping, args):' | |||
|
218 | 218 | yield joiner |
|
219 | 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 | 230 | methods = { |
|
222 | 231 | "string": lambda e, c: (runstring, e[1]), |
|
223 | 232 | "symbol": lambda e, c: (runsymbol, e[1]), |
@@ -230,6 +239,7 b' methods = {' | |||
|
230 | 239 | |
|
231 | 240 | funcs = { |
|
232 | 241 | "join": join, |
|
242 | "sub": sub, | |
|
233 | 243 | } |
|
234 | 244 | |
|
235 | 245 | # template engine |
General Comments 0
You need to be logged in to leave comments.
Login now