mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Introduce new subfilter operator (#3508)
This commit is contained in:
parent
db3f41db29
commit
33dd367a65
33
core/modules/filters/subfilter.js
Normal file
33
core/modules/filters/subfilter.js
Normal file
@ -0,0 +1,33 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/subfilter.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator returning its operand evaluated as a filter
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.subfilter = function(source,operator,options) {
|
||||
var list = options.wiki.filterTiddlers(operator.operand,options.widget,source);
|
||||
if(operator.prefix === "!") {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
if(list.indexOf(title) === -1) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
} else {
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
@ -0,0 +1,8 @@
|
||||
created: 20181031175129475
|
||||
modified: 20181031175129475
|
||||
tags: [[subfilter Operator]] [[Operator Examples]]
|
||||
title: subfilter Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[subfilter[one two three]addsuffix[!]]">>
|
||||
<<.operator-example 2 "[subfilter{$:/StoryList!!list}]">>
|
25
editions/tw5.com/tiddlers/filters/subfilter Operator.tid
Normal file
25
editions/tw5.com/tiddlers/filters/subfilter Operator.tid
Normal file
@ -0,0 +1,25 @@
|
||||
caption: subfilter
|
||||
created: 20181031175129475
|
||||
modified: 20181031175129475
|
||||
op-input: a [[selection of titles|Title Selection]] passed as input to the subfilter
|
||||
op-neg-input: a [[selection of titles|Title Selection]] passed as input to the subfilter
|
||||
op-neg-output: those input titles that are <<.em not>> returned from the subfilter <<.place S>>
|
||||
op-output: the [[selection of titles|Title Selection]] returned from the subfilter <<.place S>>
|
||||
op-parameter: a [[filter expression|Filter Expression]]
|
||||
op-parameter-name: S
|
||||
op-purpose: select titles from the operand interpreted as a [[filter expression|Filter Expression]]
|
||||
tags: [[Filter Operators]] [[Field Operators]] [[Selection Constructors]] [[Negatable Operators]]
|
||||
title: subfilter Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.18">> Note that the subfilter operator was introduced in version 5.1.18 and is not available in earlier versions.
|
||||
|
||||
<<.tip " Literal filter operands cannot contain square brackets but you can work around the issue by using a variable:">>
|
||||
|
||||
```
|
||||
<$set name="myFilter" value="[tag[one]]">
|
||||
<$list filter="[all[tiddlers]subfilter<myFilter>]">
|
||||
...
|
||||
```
|
||||
|
||||
<<.operator-examples "subfilter">>
|
Loading…
Reference in New Issue
Block a user