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[ ]] + +<> +