How can I check if <currentTiddler> has an empty list field?

157 views
Skip to first unread message

hubertgk

unread,
Jun 20, 2018, 7:14:22 AM6/20/18
to TiddlyWiki
Hi,

I'm trying to find a way to specifically check whether the current tiddler has a list field with no value.

I've found this in the documentation but the below filter does not seem to return any relevant tiddlers:

<$list filter="[<currentTiddler>has:list[emptyfield]]">

I'm not quite sure whether emptyfield itself is a valid operator or just a placeholder.

I've also tried the below filter but I guess that this filter works on the assumption that the list must exist and it's only assumed to exist if there's a value assigned to it:

<$list filter="[<currentTiddler>list[]]">

So, again no luck.

Is there a way to denote the state of emptiness in a filter? :) Or perhaps there's a better way of solving this without resorting to macro substitution too much? (I've tried that successfully with emptyValue but it overcomplicates things a bit).

Thanks in advance!

BurningTreeC

unread,
Jun 20, 2018, 8:22:32 AM6/20/18
to TiddlyWiki
Hi Hubert,

you can do so:

<$list filter="[{!!list}regexp[^$]]">
I'm empty
</$list>

the ^$ part is a regex expression
^ means the beginning of the line
$ means the end of the line
^$ in combination means that it must match an expression that starts with the beginning of the line and the next "character" must be the end of the line, which is an empty line

hope this helps,
BTC

Hubert

unread,
Jun 20, 2018, 8:38:05 AM6/20/18
to TiddlyWiki
It does, thank you very much!!

TonyM

unread,
Jun 20, 2018, 10:34:00 AM6/20/18
to TiddlyWiki
Hubert,

I discovered the following by trial that may be helpful

has[fieldname] returns tiddlers that have non-blank fields named fieldname
has:field[fieldname] returns tiddlers that have blank and non-blank fields named fieldname

List can be addressed as a field above as can tags, but list also has all the list ops handling available just as tags is just a field but has all the tag handling features available

So has:field[list] will show all tiddlers with a list field and if you then get[list] you can return the value in the field "list" and when empty this will trigger the emptyMessage on the <$list widget.

I hope this helps
Tony

Hubert

unread,
Jun 20, 2018, 11:25:11 AM6/20/18
to TiddlyWiki
Hi Tony,
That's neat -- thanks!

Thank you both again for the suggestions! Issue resolved :)

Best,
Hubert
Reply all
Reply to author
Forward
0 new messages