purpose | apply a subfilter to each input title and return the titles that return a non-empty result from the subfilter |
---|---|
input | a selection of titles passed as input to the filter |
! input | a selection of titles passed as input to the filter |
parameter | S =a filter expression |
output | the selection of titles that pass the filter S |
! output | those input titles that do not pass the filter S |
Learn more about how to use Filters
Introduced in v5.1.23 The filter
operator runs a subfilter for each input title, and returns those input titles for which the subfilter returns a non-empty result (in other words the result is not an empty list). The results of the subfilter are thrown away.
Simple filter operations can be concatenated together directly (eg [tag[HelloThere]search[po]]
) but this doesn't work when the filtering operations require intermediate results to be computed. The filter
operator can be used to filter on an intermediate result which is discarded. To take the same example but to also filter by those tiddlers whose text field is longer than 1000 characters:
<$vars myfilter="[get[text]length[]compare:integer:gteq[1000]]">
<$list filter="[tag[HelloThere]search[po]filter<myfilter>]">
<div>
<$link>
<$text text=<<currentTiddler>>/>
</$link>
</div>
</$list>
</$vars>
Note that within the subfilter, the "currentTiddler" variable is set to the title of the tiddler being processed. The value of currentTiddler outside the subfilter is available in the variable "..currentTiddler". Introduced in v5.2.0
\define larger-than-1k() [get[text]length[]compare:integer:gteq[1000]]
{{{ [tag[HelloThere]filter<larger-than-1k>] }}}
is equivalent to:
{{{ [tag[HelloThere]] :filter[get[text]length[]compare:integer:gteq[1000]] }}}