Unexpected behavior with list filter for ViewTemplate

41 views
Skip to first unread message

Andrés Pérez

unread,
Nov 1, 2019, 7:06:22 AM11/1/19
to TiddlyWiki
So this is probably me not understanding something fully, so I am asking here to be better educated. I was playing around with a viewtemplate and thought about how to apply it based on tiddler title. When I did that filter, though, it applied the template to every single tiddler.

So I have these two viewtemplate-tagged tiddlers:
Title-based:
<$list filter="[all[current]is[tiddler]!is[system]title[foobar]]">
foo
</$list>

Tag-based:
<$list filter="[all[current]is[tiddler]!is[system]tag[foobar]]">
bar
</$list>

My expectation is that the title-based viewtemplate only gets applied to a tiddler with a title of 'foobar' and the tag-based one is only applied to tiddlers with a tag of "foobar'.
What winds up happening is that the tag-based template only gets applied based on the tag, but the title-based one gets applied to all tiddlers.

I feel like this is due to something fundamental/important in how this is all put together, but I don't know what or why.

I have a working example in this link:

And a wordier description here:

With the two ViewTemplates described above, and these 3 tiddlers with no contents:
A: Title: foobar, Tag: none
B: Title: blankTiddler, Tag: none
C: Title: tagged, Tag: foobar

My expectation is that the contents of the three tiddlers be:
A: foo
B: nothing
C: bar

Actual rendered contents:
A: foo
B: foo
C: foo bar

Eric Shulman

unread,
Nov 1, 2019, 7:22:26 AM11/1/19
to TiddlyWiki
The following note appears in the documentation for https://tiddlywiki.com/#title%20Operator

title is a constructor (except in the form !title), but field:title is a modifier. 


The output of a Filter Step depends on its operator:
Most operators derive their output from their input. For example, many of them output a subset of their input, and thus truly live up to the name of "filters", narrowing down the overall output of the containing run. These operators are called selection modifiers.
A few operators ignore their input and generate an independent output instead. These are called selection constructors: they construct an entirely new selection.
A good example of a constructor is title. The output of [title[A]title[B]] is just B. But the field operator is a modifier, so [title[A]field:title[B] outputs nothing at all.

Thus, in your experiment:
"title[foobar]" is a "constructor" that always returns "foobar" regardless of what precedes it in the filter, while "field:title[foobar]" is a "modifier" that only returns "foobar" if the preceding filter terms already contain "foobar"

enjoy,
-e
Eric Shulman
TiddlyTools: "Small Tools for Big Ideas!" (tm) http://tiddlytools.github.io/
InsideTiddlyWiki: The Missing Manuals http://insidetiddlywiki.tiddlyspot.com/

Andrés Pérez

unread,
Nov 1, 2019, 11:58:44 AM11/1/19
to TiddlyWiki
That is a distinction in the operators which had completely eluded me. That was extremely helpful, thank you!
Reply all
Reply to author
Forward
0 new messages