mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
6f9cf20e77
* Added failing tests for #7155 * Pass getVariable options through to the widget method. Fixes #7155 * Whitespace fix * Added tests to verify macro parameters work inside filter, reduce, and sortsub operators
35 lines
834 B
JavaScript
35 lines
834 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/filter.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator returning those input titles that pass a subfilter
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.filter = function(source,operator,options) {
|
|
var filterFn = options.wiki.compileFilter(operator.operand),
|
|
results = [],
|
|
target = operator.prefix !== "!";
|
|
source(function(tiddler,title) {
|
|
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),options.widget.makeFakeWidgetWithVariables({
|
|
"currentTiddler": "" + title,
|
|
"..currentTiddler": options.widget.getVariable("currentTiddler","")
|
|
}));
|
|
if((list.length > 0) === target) {
|
|
results.push(title);
|
|
}
|
|
});
|
|
return results;
|
|
};
|
|
|
|
})();
|