diff --git a/core/modules/filters/get.js b/core/modules/filters/get.js new file mode 100644 index 000000000..feae6684e --- /dev/null +++ b/core/modules/filters/get.js @@ -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; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/filters/FilterOperator get.tid b/editions/tw5.com/tiddlers/filters/FilterOperator get.tid new file mode 100644 index 000000000..0b79e2287 --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/FilterOperator get.tid @@ -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 |