summaryrefslogtreecommitdiff
path: root/rules/EXPRESSIONS
diff options
context:
space:
mode:
Diffstat (limited to 'rules/EXPRESSIONS')
-rw-r--r--rules/EXPRESSIONS53
1 files changed, 42 insertions, 11 deletions
diff --git a/rules/EXPRESSIONS b/rules/EXPRESSIONS
index 55976f4..c84ebf4 100644
--- a/rules/EXPRESSIONS
+++ b/rules/EXPRESSIONS
@@ -227,18 +227,49 @@
}
}
, "contains":
- { "vars": ["list", "item"]
+ { "doc": ["Returns the item if it is in the list or \"null\" otherwise."]
+ , "vars": ["list", "item", "list_prefix"]
+ , "vars_doc":
+ { "list": ["The list to look for the item."]
+ , "item": ["The item to look for in the list."]
+ , "list_prefix":
+ [ "An optional string, which every item in the list is prefixed with"
+ , "before comparison. Note that the returned item is not prefixed."
+ ]
+ }
, "expression":
- { "type": "or"
- , "$1":
- { "type": "foreach"
- , "var": "entry"
- , "range": {"type": "var", "name": "list"}
- , "body":
- { "type": "=="
- , "$1": {"type": "var", "name": "entry"}
- , "$2": {"type": "var", "name": "item"}
- }
+ { "type": "let*"
+ , "bindings":
+ [ [ "result"
+ , { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "entry"
+ , "range": {"type": "var", "name": "list"}
+ , "body":
+ { "type": "if"
+ , "cond":
+ { "type": "=="
+ , "$1":
+ { "type": "join"
+ , "$1":
+ [ {"type": "var", "name": "list_prefix", "default": ""}
+ , {"type": "var", "name": "entry"}
+ ]
+ }
+ , "$2": {"type": "var", "name": "item"}
+ }
+ , "then": [{"type": "var", "name": "entry"}]
+ }
+ }
+ }
+ ]
+ ]
+ , "body":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "result"}
+ , "then": {"type": "join", "$1": {"type": "var", "name": "result"}}
+ , "else": null
}
}
}