1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +00:00

Add 'get' filter operator

Prompted by @sukima’s work on #586
This commit is contained in:
Jermolene 2014-04-27 18:45:01 +01:00
parent 1d0dc60a2d
commit 570cad1c7f
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/*\
title: $:/core/modules/filters/get.js
type: application/javascript
module-type: filteroperator
Filter operator for replacing tiddler titles by the value of the field specified in the operand.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.get = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
if(tiddler) {
var value = tiddler.getFieldString(operator.operand);
if(value) {
results.push(value);
}
}
});
return results;
};
})();

View File

@ -0,0 +1,12 @@
created: 20140426183123179
modified: 20140426183123179
tags: filters
title: FilterOperator: get
type: text/vnd.tiddlywiki
The ''get'' filter operator replaces the titles of the tiddlers in the current list with the values of the field specified by the operand.
For example:
|!Filter String |!Description |
|`[all[current]get[draft.of]]` |If the current tiddler is a draft, returns the original tiddler, otherwise returns an empty list |