Filter Question: Conditionally Use a ViewTemplate

I have a ViewTemplate to render tiddlers meet one of below criteria

  • tagged with thisTag
  • tagged with thatTag
  • meet any criteria defined in a tiddler called condTid

What is the simple semantic filter to be used in:

<$list filter="[all[current]] .... --> meet above conditions
...

My initial solution is:

<$list filter=" [all[current]tag[thisTag]] [all[current]tag[thatTag]] [all[current]subfilter{condTid}] :and[limit[1]]" >

....
....
</$list>

You can eliminate the :and[limit[1]] filter run by using the :else (or ~) prefix on the other filter runs:

<$list filter="[all[current]tag[thisTag]] ~[all[current]tag[thatTag]] ~[all[current]subfilter{condTid}]" >
....
</$list>

and here’s a slightly less verbose alternative:

<$list filter="[tag[thisTag]] [tag[thatTag]] [subfilter{condTid}] +[match<currentTiddler>]" >
....
</$list>

-e

1 Like

Thank you Eric!
I like your second solution specially because of +[match<currentTiddler>].

I also observe the two tag filters, could just be placed inside the condTid tiddler.

Perhaps yes, perhaps no… depends on the intended use-case. Consider: suppose you want to allow the user to enter the contents of condTid using an $edit-text or $select widget but, in addition, want to ensure that the resulting filter can always find a tiddler that has been tagged with either thisTag or thatTag, regardless of the user’s input in “condTid”.

-e