Confused about reference to an empty variable in a filter

28 views
Skip to first unread message

soren.b...@gmail.com

unread,
Nov 22, 2020, 11:27:35 AM11/22/20
to TiddlyWiki
I'm trying to create a template that will take a value from a variable, if present, or from a field of the current tiddler if the variable isn't defined. My first try was this filter:

{{{ [<articleName>else{!!myarticle}] }}}

To my surprise, the else doesn't work -- the filter works as expected if articleName is defined (the value of the variable articleName is output), but the output is just empty if articleName isn't defined, instead of containing the value of the myarticle field.

But this does work as expected:

{{{ [<articleName>!is[blank]else{!!myarticle}] }}}

I don't follow why this works and the first version doesn't, though, and I couldn't find much in the manual about this, so I would be grateful if someone could enlighten me. Is there a difference between an empty-string item and an empty list, and the title constructor yields an empty-string item when used this way? Are there other situations when I should have this in mind?

Saq Imtiaz

unread,
Nov 22, 2020, 12:23:28 PM11/22/20
to TiddlyWiki
A non-existent variable is assigned a value of "", i.e a non empty string.
Which is not the same as no result from the filter step.

There is also the is[variable] operator.

Reply all
Reply to author
Forward
0 new messages