Add new "lookup" filter

This commit is contained in:
Jermolene 2017-09-07 15:48:00 +01:00
parent 1b7d9d65f4
commit aa417fe899
4 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,30 @@
/*\
title: $:/core/modules/filters/lookup.js
type: application/javascript
module-type: filteroperator
Filter operator that looks up values via a title prefix
[lookup:<field>[<prefix>]]
Prepends the prefix to the selected items and returns the specified field value
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.lookup = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push(options.wiki.getTiddlerText(operator.operand + title) || options.wiki.getTiddlerText(operator.operand + operator.suffix));
});
return results;
};
})();