Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jermolene
committed
Aug 28, 2014
1 parent
798ed46
commit dcf4e93
Showing
6 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*\ | ||
title: $:/core/modules/filters/removesuffix.js | ||
type: application/javascript | ||
module-type: filteroperator | ||
Filter operator for removing a suffix from each title in the list. Titles that do not end with the suffix are removed. | ||
\*/ | ||
(function(){ | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
/* | ||
Export our filter function | ||
*/ | ||
exports.removesuffix = function(source,operator,options) { | ||
var results = []; | ||
source(function(tiddler,title) { | ||
if(title.substr(-operator.operand.length).toLowerCase() === operator.operand.toLowerCase()) { | ||
results.push(title.substr(operator.operand.length)); | ||
} | ||
}); | ||
return results; | ||
}; | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*\ | ||
title: $:/core/modules/filters/suffix.js | ||
type: application/javascript | ||
module-type: filteroperator | ||
Filter operator for checking if a title ends with a suffix | ||
\*/ | ||
(function(){ | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
/* | ||
Export our filter function | ||
*/ | ||
exports.suffix = function(source,operator,options) { | ||
var results = []; | ||
if(operator.prefix === "!") { | ||
source(function(tiddler,title) { | ||
if(title.substr(-operator.operand.length).toLowerCase() !== operator.operand.toLowerCase()) { | ||
results.push(title); | ||
} | ||
}); | ||
} else { | ||
source(function(tiddler,title) { | ||
if(title.substr(-operator.operand.length).toLowerCase() === operator.operand.toLowerCase()) { | ||
results.push(title); | ||
} | ||
}); | ||
} | ||
return results; | ||
}; | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
editions/tw5.com/tiddlers/filters/FilterOperator removesuffix.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
created: 20140828133830424 | ||
modified: 20140828133830424 | ||
tags: filters | ||
title: FilterOperator: removesuffix | ||
type: text/vnd.tiddlywiki | ||
|
||
The ''removesuffix'' filter operator returns the titles in the current list that end with a specified suffix with the suffix removed. | ||
|
||
For example: | ||
|
||
|!Filter String |!Description | | ||
|`tid-one tid-two three +[removeprefix[tid-]]` |Returns `one`, `two` | | ||
|
||
See also [[FilterOperator: suffix]], [[FilterOperator: prefix]] and [[FilterOperator: removeprefix]]. |
15 changes: 15 additions & 0 deletions
15
editions/tw5.com/tiddlers/filters/FilterOperator suffix.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
created: 20140828133830424 | ||
modified: 20140828133830424 | ||
tags: filters | ||
title: FilterOperator: suffix | ||
type: text/vnd.tiddlywiki | ||
|
||
The ''suffix'' filter operator returns the titles in the current list that end with a specified suffix. If the ''suffix'' operator is preceded by `!` then it returns the titles that do not end with the specified suffix. | ||
|
||
For example: | ||
|
||
|!Filter String |!Description | | ||
|`[tag[task]!suffix[hidden]]` |Returns tiddlers tagged `task` whose titles do not end with `hidden` | | ||
|`[suffix[.jpg]]` |Returns tiddlers whose titles end with `.jpg` | | ||
|
||
See also [[FilterOperator: removesuffix]], [[FilterOperator: prefix]] and [[FilterOperator: removeprefix]]. |