1
0
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:
saqimtiaz 2020-11-01 18:11:46 +01:00 committed by GitHub
parent a6efc14a7c
commit e7245a709c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -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) {

View File

@ -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");