This is sort of a continuation of this discussion:
also possibly touched upon here:
I think it’s a (probably) little known fact that the enlist
operator can check if the input items are not contained in its parameter list by using the !
prefix. I surely didn’t know about that. This behavior is quite different from the non-inverted enlist
, which ignores its input and does something completely different, and thus maybe unexpected.
Now it would be consequent to have a mode that is the inverse of this inverse operation, i.e. a mode that checks if the input is contained in the parameter list. To me, one does not make sense without the other. Otherwise I’d need to get very creative in order to use the !enlist
to do what I need.
Looking at the source code for enlist
, it seems pretty straightforward to add this inverse-inverse operation, and I have it running in a developer wiki. The question is, what would be a consistent way of defining this behavior? Currently, I have added a third suffix contain
(in addition to dedupe
and raw
), but I’m not sure this is the best way.
Comments and suggestions are welcome. Maybe one day this can proposed as core feature, if done right.
Yaisog
PS: These are the lines added to enlist.js:
} else {
if(operator.suffix === "contain") {
var results = [];
source(function(tiddler,title) {
if(list.indexOf(title) !== -1) {
results.push(title);
}
});
return results;
} else {
return list;
}
}
which is basically a copy of the !
prefix definition, with the ===
replaced by a !==
.