Hi Tones.
Thank you for your answers. Theses mostly solved my problem.
* for the duplication of filter code
OK with speed. It is simple to understand if code is duplicated but it is
more awkward to maintain and who knows if the identity of most code is
really intended or just a bug? I mean, from what you tell me, I don't care
about running that code twice, but I would like to write it only once.
could I do something like:
<$set name="selectRelatedTests" text="all[current]tagging[]butfirst[]">
<$count filter="<<selectRelatedTests>>"/> tests:
<$list filter="<<selectRelatedTests>>">
!!! <$link>
<$transclude>
</$list>
</$set>
This code does not work. But wouldn't it be more clear and maintenable than
the one below:
<$count filter="<<all[current]tagging[]butfirst[]>>"/> tests:
<$list filter="<<all[current]tagging[]butfirst[]>>">
!!! <$link>
<$transclude>
</$list>
Or something along that way of thinking (with my filter being written only
once even if it means more code otherwise). Also, you can see that your
proposed solution with $list was a perfect solution for me. I keep it as is.
BTW I think I discovered a bug. Actually, the tiddler to be transcluded
begins with a definition like
; tiddlywiki
: really cool stuff
With a direct inclusion like {{myTiddler}} that's OK and the definition is
printed correctly on screen. With the inclusion through $link and
$transclude, the definition is not interpreted as wiki code but shown as
raw wiki code, whereas bullets are correctly rendered, for instance.
Shouldn't I create a ticket for this?
Le samedi 19 septembre 2020 à 01:53:09 UTC+2, TW Tones a écrit :
> Hi,
>
> *the problem in my macro "counting" is that I am duplicating code to get
> the tiddlers and count them. I have tried with auxilliary variable or
> macro, but I was unable to get it work. *
>
>
> - In many ways this is not a problem in itself unless you have very
> large data
> - You could manipulate the second filter to also count and prefix the
> output with the number, however little is gained
> - Keeping it as it is is more clear and self documenting
>
> *Also, the work to get the tiddlers would also be of use for generating my
> list. As for this one, I would need a "map" filter and a "reduce" or "join"
> filter to achieve my goal. But these do not exist. *
>
> Then we create them, but I am not sure that we can't do the equivalent
> already. I am not sufficiently well versed to build these, if you could
> define the terms as you envisage, perhaps I/others can build something.
> There is Join and split and more in filters already, but the tiddler as
> record makes this easy.
>
> *And with the tools available, I can get my list of tiddlers, and use
> strings filter operator to make something ot of it. I've read that I would
> need special attention as I want to output tiddlywiki code to be
> interpreted by TW instead of basic texts, but for the time being, just
> outputing the tw code would be so sweet! *
>
> To generate code is quite easy, but to see anything, tiddlywiki does a
> final render to html. Its understanding this that that will help you
> implement this. Many of us make use of templates as does the system to
> export json and static tiddlers. A template contains the login of the
> output and that result is evaluated (eg wikified) to generate the result.
>
> When it comes to templates some advice I got which, I have not explored in
> detail yet, is using the macro definitions to contain the template
> definitions, using $(varname)$ substitutions to incorporate dynamic content.
>
> *You mention "map" filter and a "reduce" or "join" *
> I am investigating using tiddlywiki as a tool for manipulating
> *LittleData* rather than *bigdata*. Basically to extract optimised
> decision trees etc... Then "little bit bigger data" can be logging of
> activity in tiddlywiki itself, so we can build smart analytics that
> observes the authors use of tiddlywiki, with a view to discovering things
> not evident on the surface.
>
> *Perhaps you could expand on this? *
> *If the current tiddler in my filter generated list of tiddlers is
> "fubar", I can easily transform it in "!!! [[fubar]]" or "{{fubar}}" but I
> am unable to get "!!! [[fubar]]\n{{fubar}}" because I can't duplicate
> "fubar" or don't know how to. An other possibility would be a sprintf-like
> filter or macro. *
>
> - Here your provide a pseudo code for what you want, perhaps ask for
> it in plain English?
> - I am sure the below is enough to answer, although perhaps
> technically it does?
>
> *Here is my Guess at a solution*
>
> <$list filter="[[fubar]]">
>
> !!<$link/>
> <$transclude/>
> </$list>
>
> I use list simply to set the current tiddler and use the defaults for the
> link and transclude widgets.
>
> Regards
> Tones
> On Saturday, 19 September 2020 at 03:27:41 UTC+10 [email protected]
> wrote:
>
>> I have a TW where some tiddlers are also tags. They tags themselves and a
>> bunch of other tags.
>>
>> For each of those tags, I want to tell how many tiddlers tag them and
>> make a list of them which would look like that if I do it manually (the
>> case as of now):
>>
>> !!! [[foo tiddler]]
>> {{foo tiddler}}
>>
>> !!! [[bar tidller]]
>> {{bar tiddler}}
>>
>> (the link allow me to edit them, but I want to see their contents on my
>> page.)
>>
>> As for the number of tiddlers, I have done this macro:
>> \define counting()
>> <$set name="qty" filter="[all[current]tagging[]butfirst[]count[]]">
>> <$set name="label"
>> filter="[all[current]tagging[]butfirst[]count[]compare:number:gt:[1]then[tests]else[test]]">
>> <<qty>> <<label>>
>> </$set></$set>
>> \end
>>
>> which I used like this, simply:
>>
>> <<counting>>
>>
>> and I get something like "42 tests" or "1 test". (the tagging tiddlers
>> are describing tests).
>>
>> the problem in my macro "counting" is that I am duplicating code to get
>> the tiddlers and count them. I have tried with auxilliary variable or
>> macro, but I was unable to get it work.
>>
>> Also, the work to get the tiddlers would also be of use for generating my
>> list. As for this one, I would need a "map" filter and a "reduce" or "join"
>> filter to achieve my goal. But these do not exist. And with the tools
>> available, I can get my list of tiddlers, and use strings filter operator
>> to make something ot of it. I've read that I would need special attention
>> as I want to output tiddlywiki code to be interpreted by TW instead of
>> basic texts, but for the time being, just outputing the tw code would be so
>> sweet!
>>
>> If the current tiddler in my filter generated list of tiddlers is
>> "fubar", I can easily transform it in "!!! [[fubar]]" or "{{fubar}}" but I
>> am unable to get "!!! [[fubar]]\n{{fubar}}" because I can't duplicate
>> "fubar" or don't know how to. An other possibility would be a sprintf-like
>> filter or macro.
>>
>>
>>
--
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/f91cf987-74c9-4a50-bb3d-9e6b5a693dc8n%40googlegroups.com.