*Filter vs subfilter*

In the below example, if you replace  filter<myfilter> with 
subfilter<myfilter>, you will output the text length rather than the 
tiddler titles. Go ahead and try that on tiddlywiki.com

The filter operator allows you to limit the output according to the 
criteria provided by its operand, without changing the input. The most 
common use case for subfilter is to be able to use a  text reference or 
variable as a filter.

<$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>


*Why named filter run prefixes?*
Simply put because we were running out of characters to use every time we 
want to add a new run prefix that adds new functionality. Background 
here: 
https://github.com/Jermolene/TiddlyWiki5/issues/4888#issuecomment-716663427

*else vs ~ vs :else*
As explained in the link above, existing filter run prefixes have also been 
made available as named prefixes for consistency. So *~* and *:else* are 
*identical*. (Moving forwards I would personally transition to only using 
named run prefixes, with the other single character prefixes being there 
for backwards compatibility.)

As for *else* vs *:else*, the former is a filter operator and used within a 
filter run and represents a single filter step, whereas the latter is a 
filter run prefix.  

Filter runs:
https://tiddlywiki.com/#Filter%20Run
https://tiddlywiki.com/#Filter%20Expression

Filter operators and filter steps:
https://tiddlywiki.com/#Filter%20Step
https://tiddlywiki.com/#Filter%20Operators

*else* can be used as a filter step to output a fixed string, variable or 
text reference, if the filter run so far has produced no value. (In the 
below filter the portion "else[yes]" is a filter step, where as the entire 
line is a single filter run.)

[[HelloThere]is[missing]else[yes]]

*:else* can be used to run an entire new filter run if the previous filter 
runs have provided no output.

[[HelloThere]is[missing]get[text]] :else[{config}get[text]]

The above filter expression consists of two filter runs, the second has the 
prefix :else.

I hope this helps. It's a bit tricky to know what needs explanation as I 
personally do find the existing documentation on filter syntax quite good, *if 
read carefully and in its entirety*. Hopefully others can fill in if there 
are still things that are unclear.

PRs with documentation improvements are always welcome.

Cheers,
Saq

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f0e81d8a-2f4c-4676-b711-9a5d7c178aa5o%40googlegroups.com.

Reply via email to