Add new subtiddlerfields filter operator

This commit is contained in:
Jermolene 2018-04-03 17:48:01 +01:00
parent 52319ee88a
commit 47cdf55133
3 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/*\
title: $:/core/modules/filters/subtiddlerfields.js
type: application/javascript
module-type: filteroperator
Filter operator for returning the names of the fields on the selected subtiddlers of the plugin named in the operand
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.subtiddlerfields = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
var subtiddler = options.wiki.getSubTiddler(operator.operand,title);
if(subtiddler) {
for(var fieldName in subtiddler.fields) {
$tw.utils.pushTop(results,fieldName);
}
}
});
return results;
};
})();

View File

@ -0,0 +1,8 @@
created: 20180403164143915
modified: 20180403164257147
tags: [[plugintiddlers Operator]] [[Operator Examples]]
title: subtiddlerfields Operator (Examples)
type: text/vnd.tiddlywiki
<<.operator-example 1 "[[$:/core/copyright.txt]subtiddlerfields[$:/core]]">>

View File

@ -0,0 +1,13 @@
caption: subtiddlerfields
created: 20180403164138703
modified: 20180403164644231
op-input: a [[selection|Title Selection]] of tiddler titles
op-output: all field names present in the selected tiddlers within the plugin named <<.place P>>
op-parameter: the title of a plugin
op-parameter-name: P
op-purpose: select all fields present in the selected tiddlers within a plugin
tags: [[Filter Operators]] [[Special Operators]]
title: subtiddlerfields Operator
type: text/vnd.tiddlywiki
<<.operator-examples "subtiddlerfields">>