Ticket #587 (closed enhancement: fixed)
refactor filterTiddlers() to support plugin-defined enhancements
| Reported by: | EricShulman | Owned by: | JeremyRuston |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.4 |
| Component: | core | Version: | |
| Severity: | medium | Keywords: | |
| Cc: |
Description
In order to permit use-case specific plugin-defined tag filtering logic without having to replace the entire TiddlyWiki.prototype.filterTiddlers() function definition, please refactor the following code in the TiddlyWiki.prototype.filterTiddlers() function:
switch(match[2]) {
case "tag":
this.forEachTiddler(function(title,tiddler) {
if(tiddler.isTagged(match[3]))
results.pushUnique(tiddler);
});
break;
by moving it to a separate function, like this:
TiddlyWiki.prototype.matchTags(tagexpression) {
var results=[];
this.forEachTiddler(function(title,tiddler) {
if(tiddler.isTagged(tagexpression))
results.push(tiddler);
});
return results;
}
then, the filterTiddlers() code would be simplified to:
switch(match[2]) {
case "tag":
var matched=this.matchTags(match[3]);
for (var m=0; m<matched.length; m++)
results.pushUnique(matched[m]);
break;
for additional discussion, see http://groups.google.com/group/TiddlyWikiDev/browse_frm/thread/611a7f2b5ff29dfc
Change History
Note: See
TracTickets for help on using
tickets.
