[TW5] ListWidget: Comma Separated Output

122 views
Skip to first unread message

Tobias Beer

unread,
Nov 17, 2014, 7:05:49 AM11/17/14
to tiddl...@googlegroups.com
How can I achieve a comma separated output using the ListWidget?

For example, I want...

<$list filter="[all[current]tags[]]"/>

to list all tags as 
inline links, e.g.:

TagA, TagB, TagC

I guess what I want is to be able to specify a delimiter for the list widget, preferably as wikitext.

Best wishes, Tobias.

PMario

unread,
Nov 17, 2014, 7:49:40 AM11/17/14
to tiddl...@googlegroups.com
<$list filter="[all[current]tags[]]"><<currentTiddler>>, </$list>

If you want a link have a look at: http://tiddlywiki.com/#LinkWidget

<$list filter="[all[current]tags[]]"><$link><<currentTiddler>>, </$link></$list>

-m
Message has been deleted

Tobias Beer

unread,
Nov 17, 2014, 8:04:38 AM11/17/14
to tiddl...@googlegroups.com
<$list filter="[all[current]tags[]]"><$link><<currentTiddler>></$link>, </$list>

Thanks Mario, especially for an example use of <<currentTiddler>>.

However, I don't want there to be a trailing or leading comma, hence this thread.

Best wishes, Tobias.

Stephan Hradek

unread,
Nov 17, 2014, 8:06:18 AM11/17/14
to tiddl...@googlegroups.com

That would put a superfluouse comma at the end.

I fear at the moment this has to be done like this (not tested so errors might be included)

<$list filter="[all[current]tags[]first[]]"><<currentTiddler>></$list><$list filter="[all[current]tags[]butfirst[]]">, <<currentTiddler>></$list>

Tobias Beer

unread,
Nov 17, 2014, 8:43:01 AM11/17/14
to tiddl...@googlegroups.com
Thanks Stephan, that works.


Best wishes, Tobias.

amreus

unread,
Aug 14, 2020, 6:41:55 PM8/14/20
to TiddlyWiki
Was looking for this feature and found in this old thread from 2014. Still works.   Is this still the best method for joining a list with a separator?

Mark S.

unread,
Aug 14, 2020, 6:50:22 PM8/14/20
to TiddlyWiki
There is now the join filter operator ...join[,]...

amreus

unread,
Aug 14, 2020, 7:01:37 PM8/14/20
to tiddl...@googlegroups.com
@Mark- I did see that but must not understand.  I would like to create a link for each title in the output.  When I try join, I get a single link with all the titles together.

My parameterized macro:

\define join-with(sep, filter)
<$list filter="$filter$ +[first[]]"><$link/></$list><$list filter="$filter$ +[butfirst[]]">$sep$<$link/></$list>
\end

amreus

unread,
Aug 14, 2020, 7:31:13 PM8/14/20
to TiddlyWiki
I suppose it could be done using list-links macro and a custom css class.

Mark S.

unread,
Aug 14, 2020, 7:47:01 PM8/14/20
to TiddlyWiki
Assuming your titles don't have commas in them:

<$list filter="[tag[HelloThere]join[, ]]">
<$text text=<<currentTiddler>>/>
</$list>

Mat

unread,
Aug 15, 2020, 2:23:58 AM8/15/20
to TiddlyWiki
amreus wrote:
Is this still the best method for joining a list with a separator?


<:-) 

amreus

unread,
Aug 15, 2020, 4:29:59 AM8/15/20
to TiddlyWiki

Thanks Mat. I always appreciate examples.

Here is what I had come up with last evening. It's just css to use with list-links macro.

Reply all
Reply to author
Forward
0 new messages