The important thing to understand about list filters is that, within the widget contents, <<currentTiddler>>
refers to the item output by the list, not to the tiddler that contains the widget.
- In this case,
get[example]
returns the contents of the current title’s “example” field, if it exists. This becomes the new <<currentTiddler>>
/ {{!!title}}
within the context of the list.
- That means that any field transclusions you use within the widget contents, like
{{!!example}}
, will be looking for a field called “example” on the tiddler called “Whatever you put in the example
field on the original tiddler”.
Here are a couple of functional alternatives that accomplish the same thing:
<$list filter="[all[current]has[example]]">
{{!!example}} <!-- Note that unlike get, has does not change the title value; it simply returns the input title IF that tiddler has an "example" field with anything in it. -->
</$list>
<$list filter="[all[current]get[example]]">
{{!!title}} <!-- "title" is a bit of a misnomer: it refers to the current value of the list, not necessarily an extant tiddler. Also note that you don't need !is[blank], because the list will automatically return a null result if there's nothing to "get". -->
</$list>
<$list filter="[all[current]get[example]]" variable="has-example">
{{!!example}} <!-- If we explicitly set a variable to represent the value of the list output, <<currentTiddler>> won't be overwritten, and its original value will be preserved. -->
</$list>
But, as you said, there’s a simpler way to achieve this specific result! Here’s what I’d do:
<$list filter="[all[current]has[example]]" emptyMessage="field is empty">
{{!!example}}
</$list>
emptyMessage
lets us specify a fallback value (which could be as simple or complicated as you want, even including other lists if necessary.)
And just for fun, here’s one more possibility using a conditional filter run prefix, ~
/ :else
:
<$list filter="[all[current]get[example]] ~[[field is empty]]">
{{!!title}} <!-- Remember that "title" just means "current output value" -->
</$list>
The :else
prefix can be used before whole filter runs, not just literal text/titles, so you could do something like this…
<$list filter="[all[current]get[example]] ~[all[current]get[caption]]">
… to display e.g. the tiddler’s caption (assuming it has one) if there’s nothing in the “example” field.