From 9f0bf45c36cadf532852c959dedee253927ecdc9 Mon Sep 17 00:00:00 2001 From: pmario Date: Sun, 5 May 2024 19:04:55 +0200 Subject: [PATCH] fix bug in getvariable and add a temporary test --- core/modules/filters/getvariable.js | 11 +++++++---- editions/tw5.com/tiddlers/test-getvariable.tid | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 editions/tw5.com/tiddlers/test-getvariable.tid diff --git a/core/modules/filters/getvariable.js b/core/modules/filters/getvariable.js index eb576f28d..7dfc5b28a 100644 --- a/core/modules/filters/getvariable.js +++ b/core/modules/filters/getvariable.js @@ -1,5 +1,3 @@ -const { widget } = require("../widgets/widget"); - /*\ title: $:/core/modules/filters/getvariable.js type: application/javascript @@ -19,11 +17,16 @@ Export our filter function */ exports.getvariable = function(source,operator,options) { var results = [], - operand = operator.operand, + operand = operator.operand || "text", widget = options.widget; source(function(tiddler,title) { var variable = widget.getVariableInfo(title, {}), - text = (operand === "value") ? variable.srcVariable.value : variable.text; + text = ""; + if(operand === "text") { + text = variable.text; + } else if((operand === "value") && variable.srcVariable) { + text = variable.srcVariable.value; + } results.push(text || ""); }); return results; diff --git a/editions/tw5.com/tiddlers/test-getvariable.tid b/editions/tw5.com/tiddlers/test-getvariable.tid new file mode 100644 index 000000000..f1cf427b9 --- /dev/null +++ b/editions/tw5.com/tiddlers/test-getvariable.tid @@ -0,0 +1,14 @@ +created: 20240505165315301 +modified: 20240505170435200 +tags: +title: test-getvariable +type: text/vnd.tiddlywiki + +\procedure proc() some text + +\function fn() [] + +\function xx() [[proc]] [[fn]] :map[getvariable[value]] +[join[ ]] + +<> +