mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-04-27 07:40:52 -07:00
Add new "lookup" filter
This commit is contained in:
parent
1b7d9d65f4
commit
aa417fe899
4 changed files with 66 additions and 0 deletions
30
core/modules/filters/lookup.js
Normal file
30
core/modules/filters/lookup.js
Normal 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;
|
||||
};
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue