mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 02:50:27 +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:
parent
459133cc57
commit
05280f09d7
28
core/modules/filters/addprefix.js
Normal file
28
core/modules/filters/addprefix.js
Normal 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;
|
||||
};
|
||||
|
||||
})();
|
28
core/modules/filters/addsuffix.js
Normal file
28
core/modules/filters/addsuffix.js
Normal 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;
|
||||
};
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user