conditional part of a list widget

37 views
Skip to first unread message

Ross Table

unread,
May 10, 2023, 10:03:21 AM5/10/23
to TiddlyWiki
I am using something like this;

<$list filter="[tag[Background]tag{!!title}]+[sort[]]">
<h2><$link><$view field="title"/></$link></h2>
<$transclude mode="block" field="text"/>
<hr>
</$list>

but I don't like the extra hr that it puts on the bottom... Is there a way I can test to see if its not the last item in the list and then hide that using a reveal widget?

Scott Sauyet

unread,
May 11, 2023, 9:26:58 AM5/11/23
to TiddlyWiki
You can use the counter attribute of the list widget, like this:

    <$list filter=" [tag[Background]tag{!!title}]  +[sort[]]" counter="myCounter">

    <h2><$link><$view field="title"/></$link></h2>
    <$transclude mode="block" field="text"/>
    <$list filter={{{ [<myCounter-last>!match[yes]] }}}><hr/></$list>
    </$list>

Charlie Veniot

unread,
May 11, 2023, 9:53:50 AM5/11/23
to TiddlyWiki
It might not make much of a difference performance-wise, but in my "just in case" mindset, I'd do something like this:

```
 <$list filter=" [tag[Background]tag{!!title}]  +[sort[]]" counter="myCounter">
    <$list filter="[<myCounter>!match[1]]"><hr></$list>

    <h2><$link><$view field="title"/></$link></h2>
    <$transclude mode="block" field="text"/>
    </$list>
```

Charlie Veniot

unread,
May 11, 2023, 11:47:50 AM5/11/23
to TiddlyWiki
BTW: when viewing my previous reply in Google Groups, ignore the triple tick-marks before and after the TW scripting.

Those triple tick-marks are only there so that the code, when viewed via the Talk.TiddlyWiki discourse forum, does not get mangled.

Charlie Veniot

unread,
May 11, 2023, 1:10:01 PM5/11/23
to TiddlyWiki
If you want to understand why I wrote the TW script the way I did:  The Cartesian Product: understanding what it is and avoiding it like the plague
Reply all
Reply to author
Forward
0 new messages