mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-04-26 07:11:00 -07:00
Fixes reduce, filter, and sortsub operators undefined variable exception (#7156)
* 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
This commit is contained in:
parent
fb8df29948
commit
6f9cf20e77
5 changed files with 27 additions and 6 deletions
|
|
@ -21,14 +21,15 @@ exports.filter = function(source,operator,options) {
|
|||
target = operator.prefix !== "!";
|
||||
source(function(tiddler,title) {
|
||||
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
getVariable: function(name,opts) {
|
||||
opts = opts || {};
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return options.widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return options.widget.getVariable(name);
|
||||
return options.widget.getVariable(name,opts);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ exports.reduce = function(source,operator,options) {
|
|||
for(var index=0; index<results.length; index++) {
|
||||
var title = results[index],
|
||||
list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
getVariable: function(name,opts) {
|
||||
opts = opts || {};
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
|
|
@ -42,7 +43,7 @@ exports.reduce = function(source,operator,options) {
|
|||
case "length":
|
||||
return "" + results.length;
|
||||
default:
|
||||
return options.widget.getVariable(name);
|
||||
return options.widget.getVariable(name,opts);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,14 +26,15 @@ exports.sortsub = function(source,operator,options) {
|
|||
var r = filterFn.call(options.wiki,function(iterator) {
|
||||
iterator(options.wiki.getTiddler(title),title);
|
||||
},{
|
||||
getVariable: function(name) {
|
||||
getVariable: function(name,opts) {
|
||||
opts = opts || {};
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return options.widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return options.widget.getVariable(name);
|
||||
return options.widget.getVariable(name,opts);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue