mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-20 19:29:43 +00:00
17711657b6
Fixes #4147
31 lines
574 B
JavaScript
31 lines
574 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/else.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator for replacing an empty input list with a constant, passing a non-empty input list straight through
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.else = function(source,operator,options) {
|
|
var results = [];
|
|
source(function(tiddler,title) {
|
|
results.push(title);
|
|
});
|
|
if(results.length === 0) {
|
|
return [operator.operand];
|
|
} else {
|
|
return results;
|
|
}
|
|
};
|
|
|
|
})();
|