1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Add "enlist" operator

Fixes #2767
This commit is contained in:
Jermolene 2017-02-21 15:17:47 +00:00
parent b1ecf81b0c
commit cd2bc88658
3 changed files with 65 additions and 0 deletions

View 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;
}
};
})();

View 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}]">>

View 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">>