Is it possible to get the size of a list filter into a variable?

119 views
Skip to first unread message

Jeff Vance

unread,
Feb 5, 2017, 1:23:55 PM2/5/17
to TiddlyWiki
I'm not sure if this is possible.  I'm assuming it isn't since I've tried many things.  What I'm doing is I created a macro to generate a table of links, organized by certain tags they have.  It's using HTML table syntax since the size of the table is dynamic, it is easy to just keep adding rows of each entry found by the List widget.  

It's very similar to the filter operator table in the TW documentation here: http://tiddlywiki.com/#Filter%20Operators

The problem is, I want the left-most column to contain a row header for that group of tiddlers in the table share. So that cell must span the number of rows that will be generated.  For example, the filter says, get a list of all tiddlers with tag TBD, (say there are 5 of them), now create Row header with rowspan="5" displaying TBD as a title, now list links to the 5 tiddlers to the right of that row header.  If there are always 5, it works perfectly with the TBD row header spanning the 5 rows of links.  But this needs to support any number of tiddlers.  But it seems there is no possible way to get the size of the filter list and pass this to the rowspan attribute.  <$count> does not help since that seems to only wikify the result for displaying.  

Is there any way to accomplish this? I'm honestly a little surprised TW5 doesn't already have a special operator or default variable to capture a list size.  Seems like the list widget could be enhanced to automatically set a variable equal to the size of the list.


Mat

unread,
Feb 5, 2017, 2:50:21 PM2/5/17
to TiddlyWiki

Jed Carty

unread,
Feb 5, 2017, 3:09:08 PM2/5/17
to TiddlyWiki
The problem is that the list widget does everything. Almost every component of tiddlywiki that is displayed is displayed inside a list widget, from the order of the tiddlers in the story river to the buttons on each tiddler. Unfortunately this means that anything you do to the list widget has unintended consequences. a while ago Tobias made a modification to the list widget that would give you the index of the current item of the list. It was very useful, unfortunately it turns out that it also interferes with some of the optimisations needed to make tiddlywiki run reasonably.

Recently there has been some more discussion about this and I think that the current consensus is that we should just make another widget that does what the list widget does but without the optimisation so we can include things like giving a count of the number of things in a list. I think someone said they would work on it but I don't know if any progress has been made.

Jeremy Ruston

unread,
Feb 5, 2017, 3:26:21 PM2/5/17
to tiddl...@googlegroups.com
Hi Jeff, Jed,

> Is it possible to get the size of a list filter into a variable?

Not currently, no. There’s an enhancement already in the 5.1.14 prerelease that provides part of the answer: filtered transcluded attributes. These are attributes that return the first entry of a filtered list. For example:

<div data-my-value={{{ [<currentTiddler>get[document]] }}}>

The other part is that we need a “count” filter operator (at the moment, there’s only a count widget. The count filter operator would allow one to do things like:

<table colspan={{{ [tag[special]count[]] }}}>

I think it’s worth adding a “count” filter; I’ve also come across cases where it would be useful.

> The problem is that the list widget does everything. Almost every component of tiddlywiki that is displayed is displayed inside a list widget, from the order of the tiddlers in the story river to the buttons on each tiddler. Unfortunately this means that anything you do to the list widget has unintended consequences. a while ago Tobias made a modification to the list widget that would give you the index of the current item of the list. It was very useful, unfortunately it turns out that it also interferes with some of the optimisations needed to make tiddlywiki run reasonably.

To clarify, Jed’s referring to the fact that we can’t extend the list widget to provide a variable with the count of the number of entries because it is optimised to re-use the widget and DOM trees of list entries through the insertion and deletion of entries.

> Recently there has been some more discussion about this and I think that the current consensus is that we should just make another widget that does what the list widget does but without the optimisation so we can include things like giving a count of the number of things in a list. I think someone said they would work on it but I don't know if any progress has been made.

Good idea. We need a name for the new widget; perhaps “repeat” or “loop”? (Possibly best discussed via a GitHub ticket, if there isn’t one already)

Best wishes

Jeremy.



On 5 Feb 2017, at 20:09, Jed Carty <inmy...@gmail.com> wrote:

The problem is that the list widget does everything. Almost every component of tiddlywiki that is displayed is displayed inside a list widget, from the order of the tiddlers in the story river to the buttons on each tiddler. Unfortunately this means that anything you do to the list widget has unintended consequences. a while ago Tobias made a modification to the list widget that would give you the index of the current item of the list. It was very useful, unfortunately it turns out that it also interferes with some of the optimisations needed to make tiddlywiki run reasonably.

Recently there has been some more discussion about this and I think that the current consensus is that we should just make another widget that does what the list widget does but without the optimisation so we can include things like giving a count of the number of things in a list. I think someone said they would work on it but I don't know if any progress has been made.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/85e52fd9-b55d-4b7a-b159-0eabff6acc2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Vance

unread,
Feb 5, 2017, 4:04:42 PM2/5/17
to TiddlyWiki
Using limit operator with 1 looks like a pretty handy idea (I'll keep it in mind), but it doesn't quite help with my current problem. It looks like that just helps you determine if the list is empty or not. I'm trying to get the exact size of the list.

Jeff Vance

unread,
Feb 5, 2017, 4:40:18 PM2/5/17
to tiddl...@googlegroups.com
Hi Jeremy,

Your example of a count filter operator is exactly what I'm looking for!  Looks like I'll just have to make do without this for now.  Although I'm excited to see that you're considering adding this. I'm assuming there must be other cases that a count operator would be useful.


Tobias Beer

unread,
Feb 5, 2017, 5:02:45 PM2/5/17
to TiddlyWiki
Hi Jeff,

Perhaps tobibeer/count may help some?


Best wishes,

Tobias.

 
Reply all
Reply to author
Forward
0 new messages