mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
Modify the is operator to allow multiple types to be specified. (#2982)
* Modify the is operator to allow multiple types to be specified. * Fixed indentation. * Fixed indentation. * Rewritten to maintain input order when multiple filters provided. * Updated documentation. * Update is.tid
This commit is contained in:
parent
2163302190
commit
5ea6c9a273
|
@ -26,16 +26,9 @@ function getIsFilterOperators() {
|
||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.is = function(source,operator,options) {
|
exports.is = function(source,operator,options) {
|
||||||
// Dispatch to the correct isfilteroperator
|
|
||||||
var isFilterOperators = getIsFilterOperators();
|
|
||||||
if(operator.operand) {
|
if( !operator.operand) {
|
||||||
var isFilterOperator = isFilterOperators[operator.operand];
|
|
||||||
if(isFilterOperator) {
|
|
||||||
return isFilterOperator(source,operator.prefix,options);
|
|
||||||
} else {
|
|
||||||
return [$tw.language.getString("Error/IsFilterOperator")];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Return all tiddlers if the operand is missing
|
// Return all tiddlers if the operand is missing
|
||||||
var results = [];
|
var results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
|
@ -43,6 +36,31 @@ exports.is = function(source,operator,options) {
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get our isfilteroperators
|
||||||
|
var isFilterOperators = getIsFilterOperators(),
|
||||||
|
subops = operator.operand.split("+"),
|
||||||
|
filteredResults = {},
|
||||||
|
results = [];
|
||||||
|
for (var t=0; t<subops.length; t++) {
|
||||||
|
var subop = isFilterOperators[subops[t]];
|
||||||
|
if(subop) {
|
||||||
|
filteredResults[subops[t]] = subop(source,operator.prefix,options);
|
||||||
|
} else {
|
||||||
|
return [$tw.language.getString("Error/IsFilterOperator")];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
for (var t=0; t<subops.length; t++) {
|
||||||
|
if (filteredResults[subops[t]].indexOf(title) != -1){
|
||||||
|
results.push(title);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -11,3 +11,4 @@ type: text/vnd.tiddlywiki
|
||||||
<<.operator-example 5 "[all[shadows]is[system]tag[$:/tags/Stylesheet]]" "shadow system stylesheets">>
|
<<.operator-example 5 "[all[shadows]is[system]tag[$:/tags/Stylesheet]]" "shadow system stylesheets">>
|
||||||
<<.operator-example 6 "[is[shadow]]" "overridden shadow tiddlers">>
|
<<.operator-example 6 "[is[shadow]]" "overridden shadow tiddlers">>
|
||||||
<<.operator-example 7 "[is[missing]]" "empty because its input contains only tiddlers that exist">>
|
<<.operator-example 7 "[is[missing]]" "empty because its input contains only tiddlers that exist">>
|
||||||
|
<<.operator-example 8 "[all[tiddlers+shadows]is[tiddler+shadow]]" "contains the entire input list">>
|
||||||
|
|
|
@ -11,7 +11,11 @@ op-parameter-name: C
|
||||||
op-output: those input tiddlers that belong to category <<.place C>>
|
op-output: those input tiddlers that belong to category <<.place C>>
|
||||||
op-neg-output: those input tiddlers that do <<.em not>> belong to category <<.place C>>
|
op-neg-output: those input tiddlers that do <<.em not>> belong to category <<.place C>>
|
||||||
|
|
||||||
The parameter <<.place C>> is one of the following fundamental categories:
|
The parameter <<.place C>> specifies zero or more fundamental categories using the following syntax:
|
||||||
|
|
||||||
|
<$railroad text="""
|
||||||
|
[{: ("current" | "missing" |: "orphans" | "shadows" | "tags" | "tiddlers" ) +"+" }]
|
||||||
|
"""/>
|
||||||
|
|
||||||
|!Category |!Matches any tiddler that... |
|
|!Category |!Matches any tiddler that... |
|
||||||
|^`current` |is the [[current tiddler|Current Tiddler]] |
|
|^`current` |is the [[current tiddler|Current Tiddler]] |
|
||||||
|
|
Loading…
Reference in New Issue
Block a user