fix bug in getvariable and add a temporary test

This commit is contained in:
pmario 2024-05-05 19:04:55 +02:00
parent 3187d32cad
commit 9f0bf45c36
2 changed files with 21 additions and 4 deletions

View File

@ -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;

View File

@ -0,0 +1,14 @@
created: 20240505165315301
modified: 20240505170435200
tags:
title: test-getvariable
type: text/vnd.tiddlywiki
\procedure proc() some text
\function fn() [<proc>]
\function xx() [[proc]] [[fn]] :map[getvariable[value]] +[join[ ]]
<<xx>>