1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-05 01:26:18 +00:00

Set currentTiddler and ..currentTiddler for filter evaulation

This commit is contained in:
jeremy@jermolene.com 2021-11-04 16:20:37 +00:00
parent fc3a764199
commit 9e41d410ee
2 changed files with 13 additions and 2 deletions

View File

@ -21,7 +21,18 @@ exports.cascade = function(operationSubFunction,options) {
$tw.utils.each(inputResults,function(title) {
var result = ""; // If no filter matches, we return an empty string
$tw.utils.each(filterList,function(filter) {
var output = options.wiki.filterTiddlers(filter,widget,options.wiki.makeTiddlerIterator([title]));
var output = options.wiki.filterTiddlers(filter,{
getVariable: function(name) {
switch(name) {
case "currentTiddler":
return "" + title;
case "..currentTiddler":
return widget.getVariable("currentTiddler");
default:
return widget.getVariable(name);
}
}
},options.wiki.makeTiddlerIterator([title]));
if(output.length !== 0) {
result = output[0];
return false;

View File

@ -295,7 +295,7 @@ describe("'reduce' and 'intersection' filter prefix tests", function() {
});
wiki.addTiddler({
title: "$:/filter2",
text: "[tag[shopping]then[It is not customary]]",
text: "[<currentTiddler>tag[shopping]then[It is not customary]]",
tags: "$:/tags/Filter"
});
wiki.addTiddler({