Saq Et al,
Some thinking an experiments. I miss the TWC For Each Tiddler macro, which
the following comes closer to. Such changes could be added to a new widget,
as the ;list widget is busy, similar to the list Widget such as
"list-report Widget", permitting more than one value to be extracted from
inside the filter.
On prerelease we now have a counter variable which allows the following;
<$list filter="[tag[Widgets]sort[title]]" counter=item>
<<item>>. <$link/><br>
</$list>
In the above you can see there are two variables available inside the list,
the currentTiddler (or named variable) and now the named counter in this
case item.
The thing is we use the title or currentTiddler interchangeably with only
one output. We can addprefixes and generate new tiddler titles, extract a
field but do not have access to the tiddler title we used to generate it. I
was thinking what if we could assign the currentTiddler (result) to a
variable in a filter making the currentTiddler available in the
list/template.
<$list filter="[tag[Widgets]sort[title]var:varname[]]
+[get[caption]else{!!title}]">
<<currentTiddler>> <<varname>><br>
</$list>
OR
<$list filter="[tag[Widgets]sort[title]] :var:description{!!description}]
+[get[caption]else{!!title}]">
<<currentTiddler>> - <<description>> <br>
</$list>
In the Above cases for each iteration of the list the currentTiddler would
be the caption or title, but varname would contain the original tiddler
title, keeping in mind you may not see it if the given tiddler is
eliminated from the output.
Basically for each iteration of the first run above the output title will
be stored in varname and passed on to the next run.
If this could be done more than once a lot could be extracted from one list.
*Using counter*
You could actually use the counter (less 1) as the select value in a set
statement, to turn the counter into a reference to a tiddler.
<$set name=widget-list filter="[tag[Widgets]sort[title]]">
<$list filter="[enlist<widget-list>]" counter=item>
<<item>>. <$link/> {{!!caption}}
''Use set select with filter=<<widget-list>> here!''<br>
</$list>
</$set>
Tones
On Tuesday, 15 June 2021 at 10:37:02 UTC+10 TW Tones wrote:
> Saq,
>
> Could you give some idea of how/why* It is going to be used in a context
> where other wikitext cannot be introduced. ?*
>
> - Do you want it in a "filtered transclusion"? see below
>
>
> Of course the following does what you want but the currentTiddler is not
> available inside the list.
>
> <$list filter="[tag[Widgets]sort[title]] +[get[caption]else{!!title}]">
>
> </$list>
>
> This also achieves the same?
> In the template you have access to the current tiddler, in the same way as
> my first response with an inline template?
>
> <$list filter="[tag[Widgets]sort[title]]" template="caption-or-title">
>
> </$list>
>
> Where caption-or-title contains
> {{{ [all[current]get[caption]else{!!title}] }}}<br>
>
> *In a filtered transclusion you can use a template*
> {{{ [tag[Widgets]sort[title]]||caption-or-title}}}
>
> I am interested in the challenge.
>
> Regards
> Tones
> On Tuesday, 15 June 2021 at 09:18:48 UTC+10 Saq Imtiaz wrote:
>
>>
>>> Is the demand for a single filter expression a needed constraint?
>>>
>>
>> Yes. It is going to be used in a context where other wikitext cannot be
>> introduced.
>> It is possible with the filter expression I posted but I'm curious if
>> I've missed a simpler solution.
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/50892f56-e9a7-41ee-b645-16d391b33d2en%40googlegroups.com.