1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add [is[tag]] filter operator

This commit is contained in:
Jermolene 2014-04-18 17:57:55 +01:00
parent 869cec1ccc
commit 15d0c27e2a
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,37 @@
/*\
title: $:/core/modules/filters/is/tag.js
type: application/javascript
module-type: isfilteroperator
Filter function for [is[tag]]
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.tag = function(source,prefix,options) {
var results = [],
tagMap = options.wiki.getTagMap();
if(prefix === "!") {
source(function(tiddler,title) {
if(!$tw.utils.hop(tagMap,title)) {
results.push(title);
}
});
} else {
source(function(tiddler,title) {
if($tw.utils.hop(tagMap,title)) {
results.push(title);
}
});
}
return results;
};
})();

View File

@ -1,5 +1,5 @@
created: 20140410103123179
modified: 20140410103123179
modified: 20140418103123179
tags: filters commonfilters
title: FilterOperator: is
type: text/vnd.tiddlywiki
@ -13,6 +13,7 @@ The ''is'' filter operator selects tiddlers from the current list according to t
* `[is[shadow]]` - tiddlers that are ShadowTiddlers
* `[is[system]]` - tiddlers that are SystemTiddlers
* `[is[tiddler]]` - tiddlers that are not MissingTiddlers
* `[is[tag]]` - tiddlers that are being used as tags
For example:
@ -20,6 +21,8 @@ For example:
|`[tag[task]is[shadow]]` |Returns ShadowTiddlers tagged `task` |
|`[tag[task]!is[system]]` |Returns non-SystemTiddlers tagged `task` |
|`[is[shadow]]` |Returns ShadowTiddlers that have been overridden by a 'real' tiddler |
|`[!is[shadow]]` |Returns ordinary tiddlers that are not shadow tiddlers |
|`[!is[tag]]` |Returns all tiddlers that are not being used as tags |
|`[is[missing]]` |Returns an empty list (see note below) |
Note that the ''is'' filter operator strictly filters the current list by choosing whether or not to include each one in the output. It never adds tiddlers to the results that are not already listed. This means that when used at the start of a run of filter operators the ''is'' operator will be choosing from the currently existing tiddlers, and so will never return missing tiddlers, or shadow tiddlers that haven't been overridden.