mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Add string operator enlist-input[] (#4948)
* Add string operator titlelist[] * Update strings.js * Update strings.js * Add tests
This commit is contained in:
parent
a6efc14a7c
commit
e7245a709c
@ -56,14 +56,14 @@ exports.trim = function(source,operator,options) {
|
||||
return result;
|
||||
};
|
||||
|
||||
// makeStringBinaryOperator(
|
||||
// function(a) {return [$tw.utils.trim(a)];}
|
||||
// );
|
||||
|
||||
exports.split = makeStringBinaryOperator(
|
||||
function(a,b) {return ("" + a).split(b);}
|
||||
);
|
||||
|
||||
exports["enlist-input"] = makeStringBinaryOperator(
|
||||
function(a) {return $tw.utils.parseStringArray("" + a);}
|
||||
);
|
||||
|
||||
exports.join = makeStringReducingOperator(
|
||||
function(accumulator,value,operand) {
|
||||
if(accumulator === null) {
|
||||
|
@ -160,6 +160,13 @@ function runTests(wiki) {
|
||||
expect(wiki.filterTiddlers("[enlist[one two three]addsuffix[!]]").join(",")).toBe("one!,two!,three!");
|
||||
});
|
||||
|
||||
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]] [[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("[[]] +[enlist-input[]]").join(",")).toBe("");
|
||||
});
|
||||
|
||||
it("should handle the then and else operators", function() {
|
||||
expect(wiki.filterTiddlers("[modifier[JoeBloggs]then[Susi]]").join(",")).toBe("Susi");
|
||||
expect(wiki.filterTiddlers("[!modifier[JoeBloggs]then[Susi]]").join(",")).toBe("Susi,Susi,Susi,Susi,Susi,Susi,Susi,Susi");
|
||||
|
Loading…
Reference in New Issue
Block a user