1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 13:29:56 +00:00

Added new filter operator for adding prefixes and suffixes to titles; these new filter operators are useful in contexts where only a filter expression is allowed and where macro processing isn't allowed. The filters complement the existing remove suffix and prefix filter operators. (So much for the "filter" in filter operator.)

This commit is contained in:
TheDiveO 2014-09-30 23:01:32 +02:00
parent 459133cc57
commit 05280f09d7
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,28 @@
/*\
title: $:/core/modules/filters/addprefix.js
type: application/javascript
module-type: filteroperator
Filter operator for adding a prefix to each title in the list. This is
especially useful in contexts where only a filter expression is allowed
and macro substitution isn't available.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.addprefix = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push(operator.operand + title);
});
return results;
};
})();

View File

@ -0,0 +1,28 @@
/*\
title: $:/core/modules/filters/addsuffix.js
type: application/javascript
module-type: filteroperator
Filter operator for adding a suffix to each title in the list. This is
especially useful in contexts where only a filter expression is allowed
and macro substitution isn't available.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.addsuffix = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push(title + operator.operand);
});
return results;
};
})();