mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
"dedupe" and "raw" suffixes for enlist-input operator (#5152)
Includes unit tests.
This commit is contained in:
parent
8fc6910c03
commit
fd3e77d38f
@ -61,7 +61,7 @@ exports.split = makeStringBinaryOperator(
|
|||||||
);
|
);
|
||||||
|
|
||||||
exports["enlist-input"] = makeStringBinaryOperator(
|
exports["enlist-input"] = makeStringBinaryOperator(
|
||||||
function(a) {return $tw.utils.parseStringArray("" + a);}
|
function(a,o,s) {return $tw.utils.parseStringArray("" + a,(s === "raw"));}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.join = makeStringReducingOperator(
|
exports.join = makeStringReducingOperator(
|
||||||
@ -78,7 +78,7 @@ function makeStringBinaryOperator(fnCalc) {
|
|||||||
return function(source,operator,options) {
|
return function(source,operator,options) {
|
||||||
var result = [];
|
var result = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
Array.prototype.push.apply(result,fnCalc(title,operator.operand || ""));
|
Array.prototype.push.apply(result,fnCalc(title,operator.operand || "",operator.suffix || ""));
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
@ -184,6 +184,9 @@ function runTests(wiki) {
|
|||||||
|
|
||||||
it("should handle the enlist-input operator", function() {
|
it("should handle the enlist-input operator", function() {
|
||||||
expect(wiki.filterTiddlers("[[one two three]enlist-input[]]").join(",")).toBe("one,two,three");
|
expect(wiki.filterTiddlers("[[one two three]enlist-input[]]").join(",")).toBe("one,two,three");
|
||||||
|
expect(wiki.filterTiddlers("[[one two two three]enlist-input[]]").join(",")).toBe("one,two,three");
|
||||||
|
expect(wiki.filterTiddlers("[[one two two three]enlist-input:dedupe[]]").join(",")).toBe("one,two,three");
|
||||||
|
expect(wiki.filterTiddlers("[[one two two three]enlist-input:raw[]]").join(",")).toBe("one,two,two,three");
|
||||||
expect(wiki.filterTiddlers("[[one two three]] [[four five six]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six");
|
expect(wiki.filterTiddlers("[[one two three]] [[four five six]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six");
|
||||||
expect(wiki.filterTiddlers("[[one two three]] [[four five six]] [[seven eight]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six,seven,eight");
|
expect(wiki.filterTiddlers("[[one two three]] [[four five six]] [[seven eight]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six,seven,eight");
|
||||||
expect(wiki.filterTiddlers("[[]] +[enlist-input[]]").join(",")).toBe("");
|
expect(wiki.filterTiddlers("[[]] +[enlist-input[]]").join(",")).toBe("");
|
||||||
|
@ -4,6 +4,8 @@ modified: 20201102221854719
|
|||||||
op-input: a [[selection of titles|Title Selection]]
|
op-input: a [[selection of titles|Title Selection]]
|
||||||
op-output: the titles stored as a [[title list|Title List]] in each input title
|
op-output: the titles stored as a [[title list|Title List]] in each input title
|
||||||
op-purpose: select titles by interpreting each input title as a [[title list|Title List]]
|
op-purpose: select titles by interpreting each input title as a [[title list|Title List]]
|
||||||
|
op-suffix: `dedupe` (the default) to remove duplicates, `raw` to leave duplicates untouched
|
||||||
|
op-suffix-name: D
|
||||||
tags: [[Filter Operators]] [[String Operators]] [[Selection Constructors]]
|
tags: [[Filter Operators]] [[String Operators]] [[Selection Constructors]]
|
||||||
title: enlist-input Operator
|
title: enlist-input Operator
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
|
@ -7,4 +7,6 @@ type: text/vnd.tiddlywiki
|
|||||||
<<.operator-example 1 "[[Days of the Week]get[list]enlist-input[]]">>
|
<<.operator-example 1 "[[Days of the Week]get[list]enlist-input[]]">>
|
||||||
Contrast with: <<.operator-example 2 "[[Days of the Week]get[list]]">>
|
Contrast with: <<.operator-example 2 "[[Days of the Week]get[list]]">>
|
||||||
<<.operator-example 3 "'HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input[]]">>
|
<<.operator-example 3 "'HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input[]]">>
|
||||||
Contrast with: <<.operator-example 4 "'HelloThere GettingStarted [[Customise TiddlyWiki]]'">>
|
Contrast with: <<.operator-example 4 "'HelloThere GettingStarted [[Customise TiddlyWiki]]'">>
|
||||||
|
<<.operator-example 5 "'HelloThere HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input:raw[]]">>
|
||||||
|
Contrast with: <<.operator-example 6 "'HelloThere HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input[]]">>
|
||||||
|
Loading…
Reference in New Issue
Block a user