Hi,
I have worked a lot with compiled filters now but this one here... I just
don't get it.
If you open tiddlywiki.com and a firebug (or similar) browser-console and
enter
var filter = "[title[Get the Ring]] [title[Kill the Dragon]]";
var compiledFilter = $tw.wiki.compileFilter(filter);
var changedTiddlers = { "Get the Ring": {"modified": true} };
var source = function(iterator) {
$tw.utils.each(changedTiddlers, function(property, title) {
var tiddler = $tw.wiki.getTiddler(title);
console.log(title);
iterator(tiddler, title);
});
};
var results = compiledFilter.call($tw.wiki, source);
console.log(results);
// outputs ["Get the Ring", "Kill the Dragon"]
Why doesn't it only display "Get the Ring"?
In fact, the compiled filter call does not even call the source function.
Consider this
var filter = "[title[Get the Ring]] [title[Kill the Dragon]]";
var compiledFilter = $tw.wiki.compileFilter(filter);
var changedTiddlers = { "Get the Ring": {"modified": true} };
var source = function(iterator) {
console.log("hello woooooorld");
};
var results = compiledFilter.call($tw.wiki, source);
console.log(results);
// outputs ["Get the Ring", "Kill the Dragon"]
But the filter is valid, if you enter it in tiddlywiki.com advanced search
it will find the tiddlers
An example that works perfectly but the filter is different:
var compiledFilter = $tw.wiki.compileFilter("[tag[task]]");
var changedTiddlers = { "Get the Ring": {"modified": true}, "bla": {
"modified": true} };
var source = function(iterator) {
$tw.utils.each(changedTiddlers, function(property, title) {
var tiddler = $tw.wiki.getTiddler(title);
console.log(title);
iterator(tiddler, title);
});
};
var results = compiledFilter.call($tw.wiki, source);
console.log(results);
// = [ "Get the Ring" ]
Where is my mistake?
Thanks
Felix
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.