Buggy Filter

77 views
Skip to first unread message

Mohammad

unread,
Oct 17, 2018, 1:27:36 AM10/17/18
to tiddl...@googlegroups.com

I was working with TW5.18-pre and wrote a macro as below inside a new tiddler

\defime buggy(filter)
<$list filter='[$filter$allbefore:include{!!current-item}]' variable="myTid">
<$transclude tiddler=<<myTid>> mode="block"/>
</$list>
\end

NOTE to my mistake, I used defime instead of define


Note that, here actually the macro is bypassed as it was incorrect and this is the filter and list widget which cause the problem.

I was in preview mode, I noted TW frozen! No response for a while and then throughout a lot of Javascript!

What is the problem? Is this a bug?

-Mohammad

PMario

unread,
Oct 17, 2018, 5:49:19 AM10/17/18
to TiddlyWiki
On Wednesday, October 17, 2018 at 7:27:36 AM UTC+2, Mohammad wrote:

What is the problem?

As you found out your "defime" typo. .. So that's not a macro definition. It's just wikitext.

The list is executed with some missing parameters. eg: $filter$ because it's empty. .. So you basically transclude all tiddlers and show them with
<$transclude tiddler=<<myTid>> mode="block"/> 

It's just a long list that is transcluded.

Is this a bug?

No ... your typo.

-mario

Mohammad

unread,
Oct 17, 2018, 10:51:18 AM10/17/18
to TiddlyWiki
Yes, the filter is empty so, why the .js tiddler are transcluded?

The first tiddler transcluded is $:/library/sjcl.js

Why allbefore empty is some .js tiddlers?

I expect an empty result.

Mohammad

Jeremy Ruston

unread,
Oct 17, 2018, 11:05:32 AM10/17/18
to tiddl...@googlegroups.com
Hi Mohammad

Just to clarify what’s going on, the filter expression "[$filter$allbefore:include{!!current-item}]” is interpreted as an invocation of the filter operator “$filter$allbefore” (the $filter$ is treated literally since we’re not inside a macro) with the suffix “include” and the operand transcluded from the “current-item” field of the current tiddler. Because there usually isn’t such a field present, the operand will be read as a blank string. Meanwhile, because the filter operator doesn’t exist, the system falls back to using the “field” operator, making the whole expression equivalent to “[field:include[]]” which will look for tiddlers with a blank field “include”. Perhaps unexpectedly, the “field” operator treats tiddlers with a missing field as if the field was blank.

By the way, the technique I used to explore this filter was to run the following in the developer console of tw5.com:

$tw.wiki.parseFilter("[$filter$allbefore:include{!!current-item}]")

The result is a simple JSON representation of the syntax tree, which can help you to understand how the system is seeing the filter.

Best wishes

Jeremy.

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f61c7a66-685a-4451-853d-57b48e5312c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Oct 17, 2018, 2:18:27 PM10/17/18
to TiddlyWiki
Many thanks Jeremy for this complete explanation!

Cheers
Mohammad 
Reply all
Reply to author
Forward
0 new messages