mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-02 14:29:55 +00:00
fix bug in getvariable and add a temporary test
This commit is contained in:
parent
3187d32cad
commit
9f0bf45c36
@ -1,5 +1,3 @@
|
|||||||
const { widget } = require("../widgets/widget");
|
|
||||||
|
|
||||||
/*\
|
/*\
|
||||||
title: $:/core/modules/filters/getvariable.js
|
title: $:/core/modules/filters/getvariable.js
|
||||||
type: application/javascript
|
type: application/javascript
|
||||||
@ -19,11 +17,16 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.getvariable = function(source,operator,options) {
|
exports.getvariable = function(source,operator,options) {
|
||||||
var results = [],
|
var results = [],
|
||||||
operand = operator.operand,
|
operand = operator.operand || "text",
|
||||||
widget = options.widget;
|
widget = options.widget;
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var variable = widget.getVariableInfo(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 || "");
|
results.push(text || "");
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
|
14
editions/tw5.com/tiddlers/test-getvariable.tid
Normal file
14
editions/tw5.com/tiddlers/test-getvariable.tid
Normal 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>>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user