Macro: How convert wikified macro output as a "List"

93 views
Skip to first unread message

Mohamed Amin

unread,
Mar 2, 2021, 9:23:31 AM3/2/21
to TiddlyWiki
Hi All,

I've a set of tiddlers represent my books/novels, and I'm using the following Macro to filter my books by their "Category" and "Language" :

\define myBooks(category lang)
<$list filter="[all[tiddlers]tag[$category$]tag[$lang$]]"/>
\end

and when I run <<myBooks Novel EN>> I got a "LIST" of my "English Novels" (which is working as expected)

Now, my problem is when I try to use that Macro output as a "LIST" in other part of my code (to identify other properties like Authers, Rating, ...)

for example, I tried the following :-

<$wikify name="wkfd" text="<<myBooks Novel EN>>" >
<$list variable="myList" filter="[enlist<wkfd>]">
<<myList>>
</$list>
</$wikify>

but both "wkfd" and "myList" variables are NOT "LIST" to iterate with. 

so, what is the correct way to use that macro output as a list?

Regards

Mohamed Amin

unread,
Mar 2, 2021, 8:03:17 PM3/2/21
to TiddlyWiki
Ok, I figured it out (Thanks BTC)

\define prepEnlisting(nlst) 
[[[[$(macO)$]]]]
\end
\define myBooks(category lang)
<$list filter="[all[tiddlers]tag[$category$]tag[$lang$]]" variable="macO">
<<prepEnlisting>>
</$list>
\end

<$wikify name="wkfd" text="<<myBooks Novel EN>>" >
<$list variable="myList" filter="[enlist<wkfd>]">
Auther of : <<myList>>  is {{{[<myList>get[auther]]}}}<br>
</$list>
</$wikify>

Any other implementation for the same functionality?

Mohamed Amin

unread,
Mar 2, 2021, 8:18:03 PM3/2/21
to TiddlyWiki
Actually I used the following to keep Macro parameter "locally"

\define prepEnlisting(nlst) 
[[[[$nlst$]]]]
\end
\define myBooks(category lang)
<$list filter="[all[tiddlers]tag[$category$]tag[$lang$]]" variable="macO">
<$macrocall $name="prepEnlisting"  nlst=<<macO>> />
</$list>
\end

<$wikify name="wkfd" text="<<myBooks Novel EN>>" >
<$list variable="myList" filter="[enlist<wkfd>]">
Auther of : <<myList>>  is {{{[<myList>get[auther]]}}}<br>
</$list>
</$wikify>

Again, is there any other implementations?

Mat

unread,
Mar 3, 2021, 4:27:31 AM3/3/21
to TiddlyWiki
OK this is just to give some pointers. I did not test your (nor my) code so maybe you had good reasons for exactly how you did it and my suggestions don't work.

\define prepEnlisting(nlst) 
[[[[$nlst$]]]]
\end

Not sure why you're using all those brackets. You can probably write it in a single row like:

\define prepEnlisting() [[$(nlst)$]]

\define myBooks(category lang)
<$list filter="[all[tiddlers]tag[$category$]tag[$lang$]]" variable="macO">
<$macrocall $name="prepEnlisting"  nlst=<<macO>> />
</$list>
\end

Put triple quotes around the filters when there's a chance some item has a quote character in its name.

\define myBooks(category lang)
<$list filter="""[all[tiddlers]tag[$category$]tag[$lang$]]""" variable="macO">
<<prepEnlisting>>
</$list>
\end

 
<$wikify name="wkfd" text="<<myBooks Novel EN>>" >
<$list variable="myList" filter="[enlist<wkfd>]">
Auther of : <<myList>>  is {{{[<myList>get[auther]]}}}<br>
</$list>
</$wikify>

So the wikifywidget is supposedly very resource demanding so it is to be avoided when possible. I'd guess it works with a setwidget:

<:-)

Mat

unread,
Mar 3, 2021, 4:32:34 AM3/3/21
to TiddlyWiki
Instead of 

<$list variable="myList" filter="[enlist<wkfd>]">
Auther of : <<myList>>  is {{{[<myList>get[auther]]}}}<br>
</$list>

you don't need a variable

<$list filter="[enlist<wkfd>]">
Auther of :<$link/> or <$view field=title/>  is {{!!auther}}<br>
</$list>

<:-)

Mohamed Amin

unread,
Mar 3, 2021, 8:40:16 AM3/3/21
to TiddlyWiki
Thanks a lot Mat for your notes/pointers, I really appreciate it.

Regarding the "4 brackets"; actually I got it from this conversation , and it works OK with me, and if I used only 2 brackets, the "enlist" doesn't split the input variable.

Thanks again for your time here
Reply all
Reply to author
Forward
0 new messages