Hi Felix I think the issue is the "title" filter operator. It always inserts its operand in the output, even if it is a missing tiddler. (One consequence is that it is possible to put missing tiddlers in $:/DefaultTiddlers, and have them display at startup. I find that useful when fleshing out the skeleton of a new TW).
The "field" operator, as in "[field:title[Get the Ring]] [field:title[Kill the Dragon]]", works differently: it filters the incoming source tiddler list, and only returns tiddlers that exist in that list. http://tiddlywiki.com/#FilterOperator%3A%20field:%5B%5BFilterOperator%3A%20field%5D%5D%20%5B%5BFilterOperator%3A%20title%5D%5D Hope that helps, Best wishes Jeremy. On Fri, Nov 7, 2014 at 5:42 PM, Felix Küppers <[email protected]> wrote: > 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. > -- Jeremy Ruston mailto:[email protected] -- 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.
