Combining filter operator (in viewTemplateBodyFilter)

I have this
[[$:/state/kp-showHideBracketContents/view]text[show]] :then[[kp-showHideBracketContents/template/hideBrackets]] :else[[kp-showHideBracketContents/template/showBrackets]] in a tiddler tagged $:/tags/ViewTemplateBodyFilter with a list-before field containing $:/config/ViewTemplateBodyFilters/default.

The intended changes work as expected. How do I restrict this effect only for tiddlers tagged with “Journal” ?

I tried
[all[current]tag[Journal][$:/state/kp-showHideBracketContents/view]text[show]] :then[[kp-showHideBracketContents/template/hideBrackets]] :else[[kp-showHideBracketContents/template/showBrackets]]

and also
[all[current]tag[Journal]] +[[$:/state/kp-showHideBracketContents/view]text[show]] :then[[kp-showHideBracketContents/template/hideBrackets]] :else[[kp-showHideBracketContents/template/showBrackets]]
but didn’t work.

I’m missing something in the syntax. Pls point me in the right direction.

Put all[current]tag[Journal]then at the beginning of EACH filter run, like this:

[all[current]tag[Journal]then[$:/state/kp-showHideBracketContents/view]text[show]then[kp-showHideBracketContents/template/hideBrackets]] :else[all[current]tag[Journal]then[kp-showHideBracketContents/template/showBrackets]]

-e

Hi @KPtko

Would this work?

[[$:/state/kp-showHideBracketContents/view]text[show]] 
:then[[kp-showHideBracketContents/template/hideBrackets]] 
:else[[kp-showHideBracketContents/template/showBrackets]]
:filter[<..currentTiddler>tag[Journal]] 

Fred

Thanks. Gets the job done.

However, for my edification-
why doesn’t this work?

[[$:/state/kp-showHideBracketContents/view]text[show]] 
+[all[current]tag[Journal]] 
:then[[kp-showHideBracketContents/template/hideBrackets]] 
:else[[kp-showHideBracketContents/template/showBrackets]]

in pseudo code:
if condition1 and condition2 are TRUE
then do something
else do something else

-KP

1 Like

The “:and” filter run prefix is not really a logical AND, it takes all preceding input and replaces it by the result of its own filter. I think of it as an “eventually” run more than an “and” run.

That’s why your pseudo code doesn’t reflect what happens. If you want a logical AND, just filter more your previous result. That’s what @EricShulman proposes in his solution, and what I also proposed using another method.

Fred