Show More
@@ -596,18 +596,18 b' def if_(context, mapping, args):' | |||||
596 | elif len(args) == 3: |
|
596 | elif len(args) == 3: | |
597 | yield args[2][0](context, mapping, args[2][1]) |
|
597 | yield args[2][0](context, mapping, args[2][1]) | |
598 |
|
598 | |||
599 |
@templatefunc('ifcontains( |
|
599 | @templatefunc('ifcontains(needle, haystack, then[, else])') | |
600 | def ifcontains(context, mapping, args): |
|
600 | def ifcontains(context, mapping, args): | |
601 | """Conditionally execute based |
|
601 | """Conditionally execute based | |
602 |
on whether the item " |
|
602 | on whether the item "needle" is in "haystack".""" | |
603 | if not (3 <= len(args) <= 4): |
|
603 | if not (3 <= len(args) <= 4): | |
604 | # i18n: "ifcontains" is a keyword |
|
604 | # i18n: "ifcontains" is a keyword | |
605 | raise error.ParseError(_("ifcontains expects three or four arguments")) |
|
605 | raise error.ParseError(_("ifcontains expects three or four arguments")) | |
606 |
|
606 | |||
607 |
|
|
607 | needle = evalstring(context, mapping, args[0]) | |
608 |
|
|
608 | haystack = evalfuncarg(context, mapping, args[1]) | |
609 |
|
609 | |||
610 | if item in items: |
|
610 | if needle in haystack: | |
611 | yield args[2][0](context, mapping, args[2][1]) |
|
611 | yield args[2][0](context, mapping, args[2][1]) | |
612 | elif len(args) == 4: |
|
612 | elif len(args) == 4: | |
613 | yield args[3][0](context, mapping, args[3][1]) |
|
613 | yield args[3][0](context, mapping, args[3][1]) |
General Comments 0
You need to be logged in to leave comments.
Login now