kopia lustrzana https://github.com/miklobit/TiddlyWiki5
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.tidprint-window-tiddler
rodzic
2163302190
commit
5ea6c9a273
|
@ -26,16 +26,9 @@ function getIsFilterOperators() {
|
|||
Export our filter function
|
||||
*/
|
||||
exports.is = function(source,operator,options) {
|
||||
// Dispatch to the correct isfilteroperator
|
||||
var isFilterOperators = getIsFilterOperators();
|
||||
if(operator.operand) {
|
||||
var isFilterOperator = isFilterOperators[operator.operand];
|
||||
if(isFilterOperator) {
|
||||
return isFilterOperator(source,operator.prefix,options);
|
||||
} else {
|
||||
return [$tw.language.getString("Error/IsFilterOperator")];
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
if( !operator.operand) {
|
||||
// Return all tiddlers if the operand is missing
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
|
@ -43,6 +36,31 @@ exports.is = function(source,operator,options) {
|
|||
});
|
||||
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 6 "[is[shadow]]" "overridden shadow tiddlers">>
|
||||
<<.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-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... |
|
||||
|^`current` |is the [[current tiddler|Current Tiddler]] |
|
||||
|
|
Ładowanie…
Reference in New Issue