mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-05 17:46:19 +00:00
Merge pull request #928 from TheDiveO/filter-operators-addsufprefix
addprefix and addsuffix filter operators
This commit is contained in:
commit
65504d5d41
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
@ -0,0 +1,15 @@
|
|||||||
|
created: 20140410103123179
|
||||||
|
modified: 20140410103123179
|
||||||
|
tags: Filters
|
||||||
|
caption: addprefix
|
||||||
|
title: FilterOperator: addprefix
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
The ''addprefix'' filter operator add a prefix to all titles in the current list.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
|!Filter String |!Description |
|
||||||
|
|`one two three +[addprefix[tid-]]` |Returns `tid-one`, `tid-two`, `tid-three` |
|
||||||
|
|
||||||
|
See also [[FilterOperator: prefix]], [[FilterOperator: suffix]], [[FilterOperator: addsuffix]], [[FilterOperator: removeprefix]] and [[FilterOperator: removesuffix]].
|
@ -0,0 +1,15 @@
|
|||||||
|
created: 20140828133830424
|
||||||
|
modified: 20140902145613329
|
||||||
|
tags: Filters
|
||||||
|
caption: addsuffix
|
||||||
|
title: FilterOperator: addsuffix
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
The ''addsuffix'' filter operator adds a suffix to all titles in the current list.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
|!Filter String |!Description |
|
||||||
|
|`one two three +[addsuffix[-tid]]` |Returns `one-tid`, `two-tid`, `three-tid` |
|
||||||
|
|
||||||
|
See also [[FilterOperator: suffix]], [[FilterOperator: prefix]], [[FilterOperator: addprefix]], [[FilterOperator: removesuffix]], and [[FilterOperator: removeprefix]].
|
@ -13,4 +13,4 @@ For example:
|
|||||||
|`[tag[task]!prefix[hidden]]` |Returns tiddlers tagged `task` whose titles do not start with `hidden` |
|
|`[tag[task]!prefix[hidden]]` |Returns tiddlers tagged `task` whose titles do not start with `hidden` |
|
||||||
|`[prefix[$:/]]` |Equivalent to `[is[system]]` |
|
|`[prefix[$:/]]` |Equivalent to `[is[system]]` |
|
||||||
|
|
||||||
See also [[FilterOperator: removeprefix]], [[FilterOperator: removesuffix]] and [[FilterOperator: removesuffix]].
|
See also [[FilterOperator: removeprefix]], [[FilterOperator: removesuffix]], [[FilterOperator: removesuffix]], [[FilterOperator: addprefix]], and [[FilterOperator: addsuffix]].
|
||||||
|
@ -12,4 +12,4 @@ For example:
|
|||||||
|!Filter String |!Description |
|
|!Filter String |!Description |
|
||||||
|`tid-one tid-two three +[removeprefix[tid-]]` |Returns `one`, `two` |
|
|`tid-one tid-two three +[removeprefix[tid-]]` |Returns `one`, `two` |
|
||||||
|
|
||||||
See also [[FilterOperator: prefix]], [[FilterOperator: suffix]] and [[FilterOperator: removesuffix]].
|
See also [[FilterOperator: prefix]], [[FilterOperator: suffix]], [[FilterOperator: removesuffix]], [[FilterOperator: addprefix]], and [[FilterOperator: addsuffix]].
|
||||||
|
@ -12,4 +12,4 @@ For example:
|
|||||||
|!Filter String |!Description |
|
|!Filter String |!Description |
|
||||||
|`one-tid two-tid three +[removesuffix[-tid]]` |Returns `one`, `two` |
|
|`one-tid two-tid three +[removesuffix[-tid]]` |Returns `one`, `two` |
|
||||||
|
|
||||||
See also [[FilterOperator: suffix]], [[FilterOperator: prefix]] and [[FilterOperator: removeprefix]].
|
See also [[FilterOperator: suffix]], [[FilterOperator: prefix]], [[FilterOperator: removeprefix]], [[FilterOperator: addprefix]], and [[FilterOperator: addsuffix]].
|
||||||
|
@ -13,4 +13,4 @@ For example:
|
|||||||
|`[tag[task]!suffix[hidden]]` |Returns tiddlers tagged `task` whose titles do not end with `hidden` |
|
|`[tag[task]!suffix[hidden]]` |Returns tiddlers tagged `task` whose titles do not end with `hidden` |
|
||||||
|`[suffix[.jpg]]` |Returns tiddlers whose titles end with `.jpg` |
|
|`[suffix[.jpg]]` |Returns tiddlers whose titles end with `.jpg` |
|
||||||
|
|
||||||
See also [[FilterOperator: removesuffix]], [[FilterOperator: prefix]] and [[FilterOperator: removeprefix]].
|
See also [[FilterOperator: removesuffix]], [[FilterOperator: prefix]], [[FilterOperator: removeprefix]], [[FilterOperator: addprefix]], and [[FilterOperator: addsuffix]].
|
||||||
|
Loading…
Reference in New Issue
Block a user