Several Independent Then Filter Run Prefix When Building a Dynamic Filter

I have a case to build a dynamic filter from several independ filter runs. Some uses :then. I do it employing functions like below.
Before TW 5.2.0 I did this kind of filter building using macro and strings.

Example:


\function links.filter() [<tidlinks>match[yes]] :then[<currentTiddler>links[]]
\function backlinks.filter() [<tidbacklinks>match[yes]] :then[<currentTiddler>backlinks[]]

\function main.filter()
[function[links.filter]]
[function[backlinks.filter]]
\end

<!-- change options here to yes, or no -->
<$let tidlinks="yes" tidbacklinks="no" currentTiddler="HelloThere" >

* One: <$count filter="[[HelloThere]links[]]"/> <!-- for comparison only -->
* Two: <$count filter="[[HelloThere]backlinks[]]"/>

Compound filter:

* <$count filter="[function[main.filter]]"/>

</$let>

We know we cannot use several :then in one expression in the above example, as each :then will ignore the inputs.

Is this the correct way? What do you think? and what is your solution here?

Except for missing indentation (:slight_smile:), this reads fine to me.

But I am curious why you do

<$count filter="[function[main.filter]]"/>

instead of

<$count filter="[main.filter[]]"/>

Is there some advantage? Some difference in behavior?

I think there is no difference! Yours is even smaller and more readable!

1 Like