##// END OF EJS Templates
templater: fix ifcontains() to evaluate items argument eagerly...
Yuya Nishihara -
r28332:e9137163 default
parent child Browse files
Show More
@@ -466,7 +466,7 b' def ifcontains(context, mapping, args):'
466 raise error.ParseError(_("ifcontains expects three or four arguments"))
466 raise error.ParseError(_("ifcontains expects three or four arguments"))
467
467
468 item = stringify(args[0][0](context, mapping, args[0][1]))
468 item = stringify(args[0][0](context, mapping, args[0][1]))
469 items = args[1][0](context, mapping, args[1][1])
469 items = evalfuncarg(context, mapping, args[1])
470
470
471 if item in items:
471 if item in items:
472 yield args[2][0](context, mapping, args[2][1])
472 yield args[2][0](context, mapping, args[2][1])
@@ -3248,6 +3248,11 b' Test ifcontains function'
3248 1 is not
3248 1 is not
3249 0 is in the string
3249 0 is in the string
3250
3250
3251 $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n'
3252 2 is in the string
3253 1 is not
3254 0 is in the string
3255
3251 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
3256 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
3252 2 did not add a
3257 2 did not add a
3253 1 did not add a
3258 1 did not add a
General Comments 0
You need to be logged in to leave comments. Login now