289 on whether the item "needle" is in "haystack".""" |
289 on whether the item "needle" is in "haystack".""" |
290 if not (3 <= len(args) <= 4): |
290 if not (3 <= len(args) <= 4): |
291 # i18n: "ifcontains" is a keyword |
291 # i18n: "ifcontains" is a keyword |
292 raise error.ParseError(_("ifcontains expects three or four arguments")) |
292 raise error.ParseError(_("ifcontains expects three or four arguments")) |
293 |
293 |
294 haystack = evalfuncarg(context, mapping, args[1]) |
294 haystack = evalwrapped(context, mapping, args[1]) |
295 keytype = getattr(haystack, 'keytype', None) |
|
296 try: |
295 try: |
297 needle = evalrawexp(context, mapping, args[0]) |
296 needle = evalrawexp(context, mapping, args[0]) |
298 needle = templateutil.unwrapastype(context, mapping, needle, |
297 found = haystack.contains(context, mapping, needle) |
299 keytype or bytes) |
|
300 found = (needle in haystack) |
|
301 except error.ParseError: |
298 except error.ParseError: |
302 found = False |
299 found = False |
303 |
300 |
304 if found: |
301 if found: |
305 return evalrawexp(context, mapping, args[2]) |
302 return evalrawexp(context, mapping, args[2]) |