1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-02 12:19:11 +00:00

Add [is[tiddler]] filter operator

For selecting all non-shadow tiddlers, whether or not they are system
tiddlers
This commit is contained in:
Jermolene 2013-11-24 20:38:58 +00:00
parent 78f56ba875
commit 802fe9beae
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,43 @@
/*\
title: $:/core/modules/filters/is/tiddler.js
type: application/javascript
module-type: isfilteroperator
Filter function for [is[tiddler]]
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.tiddler = function(source,prefix,options) {
var results = [];
// Function to check a tiddler
function checkTiddler(title) {
var match = options.wiki.tiddlerExists(title);
if(prefix === "!") {
match = !match;
}
if(match) {
results.push(title);
}
};
// Iterate through the source tiddlers
if($tw.utils.isArray(source)) {
$tw.utils.each(source,function(title) {
checkTiddler(title);
});
} else {
$tw.utils.each(source,function(element,title) {
checkTiddler(title);
});
}
return results;
};
})();

View File

@ -1,6 +1,6 @@
created: 201308270800 created: 201308270800
creator: JeremyRuston creator: JeremyRuston
modified: 201309141606 modified: 201311242006
modifier: JeremyRuston modifier: JeremyRuston
tags: concepts tags: concepts
title: TiddlerFilters title: TiddlerFilters
@ -63,6 +63,7 @@ The operator defaults to `title` if omitted, so `[[HelloThere]]` is equivalent t
The operands available with the `is` operator are: The operands available with the `is` operator are:
* ''tiddler'': selects all tiddlers excluding shadows, whether or not they are SystemTiddlers
* ''system'': selects all SystemTiddlers * ''system'': selects all SystemTiddlers
* ''shadow'': selects all ShadowTiddlers * ''shadow'': selects all ShadowTiddlers
* ''current'': selects the current ContextTiddler * ''current'': selects the current ContextTiddler