diff --git a/core/modules/filters/getvariable.js b/core/modules/filters/getvariable.js index 7dfc5b28a..43451abed 100644 --- a/core/modules/filters/getvariable.js +++ b/core/modules/filters/getvariable.js @@ -16,18 +16,9 @@ Filter operator for replacing input values by the value of the variable with the Export our filter function */ exports.getvariable = function(source,operator,options) { - var results = [], - operand = operator.operand || "text", - widget = options.widget; + var results = []; source(function(tiddler,title) { - var variable = widget.getVariableInfo(title, {}), - text = ""; - if(operand === "text") { - text = variable.text; - } else if((operand === "value") && variable.srcVariable) { - text = variable.srcVariable.value; - } - results.push(text || ""); + results.push(options.widget.getVariable(title) || ""); }); return results; }; diff --git a/core/modules/filters/variables.js b/core/modules/filters/variables.js index 7b16bbc63..c92b780d2 100644 --- a/core/modules/filters/variables.js +++ b/core/modules/filters/variables.js @@ -16,58 +16,17 @@ Filter operator for returning the names of the active variables Export our filter function */ exports.variables = function(source,operator,options) { - var operands = []; - $tw.utils.each(operator.operands,function(operand,index){ - operands.push({ - name: (index + 1).toString(), - value: operand - }); - }); var names = [], - sort, - widget = options.widget, - included = (operands[0].value) ? operands[0].value : "var fn proc macro widget"; - // all will overwrite - included = ((included.indexOf("all") !== -1)) ? "var fn proc macro widget" : included; - - // variableTemplate = (operands.length > 1 && operands[1]) ? operands[1].value : "$type$ $name$($params$) $firstLine$"; - - switch(operator.suffix) { - case "raw": - sort = false; - break; - case "alphabetical": // the fallthrough is intentional. "alphabetical" is default - default: - sort = true; - break; - } + widget = options.widget; while(widget && !widget.hasOwnProperty("variables")) { widget = widget.parentWidget; } if(widget && widget.variables) { for(var variable in widget.variables) { - var varInfo = widget.getVariableInfo(variable, {}); - - // varInfo.name = variable; - // variable = $tw.utils.formatVariableString(variableTemplate, varInfo); - - if( ((included.indexOf("fn") !== -1) && varInfo.srcVariable.isFunctionDefinition ) || - ((included.indexOf("proc") !== -1) && varInfo.srcVariable.isProcedureDefinition ) || - ((included.indexOf("macro") !== -1) && varInfo.srcVariable.isMacroDefinition ) || - ((included.indexOf("widget") !== -1) && varInfo.srcVariable.isWidgetDefinition ) ) - { - names.push(variable); - } else if((included.indexOf("var") !== -1) && !varInfo.srcVariable.isFunctionDefinition && !varInfo.srcVariable.isProcedureDefinition && !varInfo.srcVariable.isMacroDefinition && !varInfo.srcVariable.isWidgetDefinition ) - { - names.push(variable); - } + names.push(variable); } } - if(sort) { - return names.sort(); - } else { - return names; - } + return names.sort(); }; })();