mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-22 14:00:03 +00:00
parent
b1ecf81b0c
commit
cd2bc88658
33
core/modules/filters/enlist.js
Normal file
33
core/modules/filters/enlist.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/enlist.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operator returning its operand parsed as a list
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter function
|
||||||
|
*/
|
||||||
|
exports.enlist = function(source,operator,options) {
|
||||||
|
var list = $tw.utils.parseStringArray(operator.operand);
|
||||||
|
if(operator.prefix === "!") {
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(list.indexOf(title) === -1) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
} else {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
8
editions/tw5.com/tiddlers/enlist Operator (Examples).tid
Normal file
8
editions/tw5.com/tiddlers/enlist Operator (Examples).tid
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
created: 20170221144328467
|
||||||
|
modified: 20170221151620898
|
||||||
|
tags: [[enlist Operator]] [[Operator Examples]]
|
||||||
|
title: enlist Operator (Examples)
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
<<.operator-example 1 "[enlist[one two three]addsuffix[!]]">>
|
||||||
|
<<.operator-example 2 "[enlist{$:/StoryList!!list}]">>
|
24
editions/tw5.com/tiddlers/enlist Operator.tid
Normal file
24
editions/tw5.com/tiddlers/enlist Operator.tid
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
caption: enlist
|
||||||
|
created: 20170221144241063
|
||||||
|
modified: 20170221151340420
|
||||||
|
op-input: ignored
|
||||||
|
op-neg-input: a [[selection of titles|Title Selection]]
|
||||||
|
op-neg-output: those input titles that are <<.em not>> listed in <<.place L>>
|
||||||
|
op-output: the titles stored as a [[title list|Title List]] at <<.place L>>
|
||||||
|
op-parameter: a [[title list|Title List]]
|
||||||
|
op-parameter-name: L
|
||||||
|
op-purpose: select titles from the operand interpreted as a [[title list|Title List]]
|
||||||
|
tags: [[Filter Operators]] [[Field Operators]] [[Selection Constructors]] [[Negatable Operators]]
|
||||||
|
title: enlist Operator
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
<<.tip " Literal filter operands cannot contain square brackets but you can work around the issue by using a variable:">>
|
||||||
|
|
||||||
|
```
|
||||||
|
<$set name="myList" value="first [[second with a space]] third">
|
||||||
|
<$list filter="[enlist<myList>]">
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<<.operator-examples "enlist">>
|
Loading…
x
Reference in New Issue
Block a user