diff --git a/core/modules/filters/is/variable.js b/core/modules/filters/is/variable.js new file mode 100644 index 000000000..fe7ea94bc --- /dev/null +++ b/core/modules/filters/is/variable.js @@ -0,0 +1,36 @@ +/*\ +title: $:/core/modules/filters/is/variable.js +type: application/javascript +module-type: isfilteroperator + +Filter function for [is[variable]] + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.variable = function(source,prefix,options) { + var results = []; + if(prefix === "!") { + source(function(tiddler,title) { + if(!title in options.widget.variables) { + results.push(title); + } + }); + } else { + source(function(tiddler,title) { + if(title in options.widget.variables) { + results.push(title); + } + }); + } + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/filters/is.tid b/editions/tw5.com/tiddlers/filters/is.tid index bd33d11a6..6e838e872 100644 --- a/editions/tw5.com/tiddlers/filters/is.tid +++ b/editions/tw5.com/tiddlers/filters/is.tid @@ -1,5 +1,5 @@ created: 20140410103123179 -modified: 20161127142329969 +modified: 20190225130632157 tags: [[Filter Operators]] [[Common Operators]] [[Negatable Operators]] title: is Operator type: text/vnd.tiddlywiki @@ -22,6 +22,7 @@ The parameter <<.place C>> is one of the following fundamental categories: |^`system` |is a [[system tiddler|SystemTiddlers]], i.e. its title starts with `$:/` | |^`tag` |is in use as a tag | |^`tiddler` |exists as a non-shadow tiddler | +|^`variable` |<<.from-version "5.1.20">> exists as a variable (whether or not it has a non-blank value) | If <<.place C>> is anything else an error message is returned. <<.from-version "5.1.14">> if <<.place C>> is blank, the output is passed through unchanged (in earlier versions an error message was returned).