Hello everyone,
I’m stuck on an issue with :cascade
filter run prefix used in a filter which is part of a <$set>
widget.
Let me show you this little example:
- I created an empty test tiddler ‘test’
- I defined a field myFilter as
[!match[apple]]
- then I wrote this code as the tiddler’s text:
Question one: is a banana an apple or a banana? It;s a {{{ banana :cascade[{!!myFilter}] }}}
<$set name='result' filter="apple :cascade[{!!myFilter}]" value='correct' emptyValue='no, they are the same!'>
Question two: is an apple different from itself? <<result>> </$set>
Now the output I could see is this:
Question one: is a banana an apple or a banana? It’s a banana
Question two: is an apple different from itself? correct
which is not completely satisfactory to me. I can easily agree, indeed, that a banana is not an apple, so I have no objection to the answer of question one, but question two’s answer puzzles me, because after all an apple is NOT different from itself! (at least as far as I know about apples)
Coming to the code, banana :cascade[{!!myFilter}]
evaluates to banana!match[apple]
if I get how :cascade
filter run prefix works, and so it outputs, indeed, ‘banana’ as expected.
Filter number two apple :cascade[{!!myFilter}]
, on the other hand, is none but [apple!match[apple]]
in disguise, and so it should evaluate to an empty string, isn’t it? If it is so, then the <$set>
widget should assign to its own variable result
the value of attribute emptyValue
, and the answer of question two should be ‘no, they are the same!’, but unfortunately this is not the case and I can see ‘correct’ as an answer, which is not correct at all but rather wrong.
Now to make a little experiment, if you replace the banana in filter one with an apple, as {{{ apple :cascade[{!!myFilter}] }}}
it correctly outputs an empty string, as filter apple!match[apple]
is expected to do, so the problem seems to be with the <$set>
widget and the assignment to its attributes value
and emptyValue
.
Is it a bug or I am going mistaken somewhere?
PS since I’m not so sure on filters’ syntax, I also tried this alternative one:
{{{ [banana] :cascade[{!!myFilter}] }}}
filter="[apple] :cascade[{!!myFilter}]"
surrounding apple and banana with square brackets. Whatever syntax is correct (or maybe both are) the result is exactly the same.
PPS I KNOW that a :cascade
statement returning just one filter is rather odd, I just wanted to make this example as simple as possible so to better highlight the problem
TiddlyWiki version 5.2.1 browser: Firefox 98.0.2