1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Add is[variable] filter

See discussion here https://groups.google.com/d/topic/tiddlywiki/4rEuAWc4EpM/discussion
This commit is contained in:
Jermolene 2019-02-25 13:08:22 +00:00
parent 810033bd71
commit 36e76429b1
2 changed files with 38 additions and 1 deletions

View File

@ -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;
};
})();

View File

@ -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).