From 9e41d410ee320e9e9f175124ea08556071d4764a Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Thu, 4 Nov 2021 16:20:37 +0000 Subject: [PATCH] Set currentTiddler and ..currentTiddler for filter evaulation --- core/modules/filterrunprefixes/cascade.js | 13 ++++++++++++- .../test/tiddlers/tests/test-prefixes-filter.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/modules/filterrunprefixes/cascade.js b/core/modules/filterrunprefixes/cascade.js index 819221f9a..f016d4346 100644 --- a/core/modules/filterrunprefixes/cascade.js +++ b/core/modules/filterrunprefixes/cascade.js @@ -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; diff --git a/editions/test/tiddlers/tests/test-prefixes-filter.js b/editions/test/tiddlers/tests/test-prefixes-filter.js index 7656633ed..a11712426 100644 --- a/editions/test/tiddlers/tests/test-prefixes-filter.js +++ b/editions/test/tiddlers/tests/test-prefixes-filter.js @@ -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: "[tag[shopping]then[It is not customary]]", tags: "$:/tags/Filter" }); wiki.addTiddler({