Skip to content

Instantly share code, notes, and snippets.

@Jermolene
Created October 6, 2016 08:14
Show Gist options
  • Save Jermolene/85d245a8d3aec60f660fc06920ad892e to your computer and use it in GitHub Desktop.
Save Jermolene/85d245a8d3aec60f660fc06920ad892e to your computer and use it in GitHub Desktop.
Experimental 'getlist' filter operator for TiddlyWiki5 - see https://github.com/Jermolene/TiddlyWiki5/issues/2598
/*\
title: $:/core/modules/filters/getlist.js
type: application/javascript
module-type: filteroperator
Filter operator returning the tiddlers whose titles are listed in the specified list fields of the selected tiddlers
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.getlist = function(source,operator,options) {
var result = [],
fieldName = operator.suffix || "list";
source(function(tiddler,title) {
$tw.utils.pushTop(result,$tw.utils.parseStringArray(tiddler.getFieldString(fieldName) || ""));
});
return result;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment