795 if not (3 <= len(args) <= 4): |
795 if not (3 <= len(args) <= 4): |
796 # i18n: "ifcontains" is a keyword |
796 # i18n: "ifcontains" is a keyword |
797 raise error.ParseError(_("ifcontains expects three or four arguments")) |
797 raise error.ParseError(_("ifcontains expects three or four arguments")) |
798 |
798 |
799 haystack = evalfuncarg(context, mapping, args[1]) |
799 haystack = evalfuncarg(context, mapping, args[1]) |
800 needle = evalastype(context, mapping, args[0], |
800 try: |
801 getattr(haystack, 'keytype', None) or bytes) |
801 needle = evalastype(context, mapping, args[0], |
802 |
802 getattr(haystack, 'keytype', None) or bytes) |
803 if needle in haystack: |
803 found = (needle in haystack) |
|
804 except error.ParseError: |
|
805 found = False |
|
806 |
|
807 if found: |
804 yield evalrawexp(context, mapping, args[2]) |
808 yield evalrawexp(context, mapping, args[2]) |
805 elif len(args) == 4: |
809 elif len(args) == 4: |
806 yield evalrawexp(context, mapping, args[3]) |
810 yield evalrawexp(context, mapping, args[3]) |
807 |
811 |
808 @templatefunc('ifeq(expr1, expr2, then[, else])') |
812 @templatefunc('ifeq(expr1, expr2, then[, else])') |