mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-12 12:55:43 +00:00
Add new "variables" and "getvariables" operators
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/getvariable.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for replacing input values by the value of the variable with the same name, or blank if the variable is missing
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.getvariable = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push(options.widget.getVariable(title) || "");
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,26 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/variables.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the names of the active variables
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.variables = function(source,operator,options) {
|
||||
var names = [];
|
||||
for(var variable in options.widget.variables) {
|
||||
names.push(variable);
|
||||
}
|
||||
return names.sort();
|
||||
};
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user