[question] transclude from within a macro ?

117 views
Skip to first unread message

Tony K

unread,
May 21, 2020, 4:37:06 AM5/21/20
to TiddlyWiki
relevant portion of the code below


\define dn-ts(timestamp)
"""<$macrocall $name="jstiddler" timestamp=$timestamp$ format="YYYY-0MM-0DD" />"""
\end


<<dn-ts 20200521065246330>>


this works and displays the time stamp is the required format i.e 2020-05-21


however what I need is to transclude the tiddler with title 2020-05-21 and that i can't achieve 

thank you 

Mark S.

unread,
May 21, 2020, 10:26:34 AM5/21/20
to TiddlyWiki
You might be able to do it with the wikify. This works with the "now" macro:

<$wikify text="""<<now "YYYY-0MM-0DD">>""" name="datetid">
<$transclude tiddler=<
<datetid>>/>
</$wikify>

But since you've already made a JS macro, maybe you could just make a version of it that returns the contents of the targeted tiddler.

Rahul Kashyap

unread,
May 23, 2020, 1:36:28 AM5/23/20
to TiddlyWiki
Hello everyone,

My problem is related. I couldn't understand your instruction completely.  Could you please elaborate more? I'll describe my problem in more details below. 
Any help would be appreciated.

I want to use a macro for all the tiddlers satisfying a certain filter esp. (demo/details/details-macro (https://kookma.github.io/TW-Shiraz/#Install) macro of Shiraz. 

I know that {{!!title}} or <$view field='title'/>  prints the title of the tiddlers  and I can use <$transclude mode="block"/> to transclude the content as well but, I couldn't transclude them inside the macro. 
I also tried a template unsuccessfully. 

<$list filter="[tag[my_tag]]">


<
<details sum:"[[tiddler_variable_in_the_loop]]" src:"{{tiddler_variable_in_the_loop}}">>   // desired output with visible link and hidden translusion


<<details sum:"{{!!title}}" src:<$transclude mode="block"/> >>   // displays the title of the tiddler without link; do not transclude.
<
<currentTiddler>>{{||$:/rkashyap/template/detail}}   // similar to above


<$transclude mode="block"/>   // transludes the whole content without hiding it
</$list>


The code below achieves the task if the title of the tiddlers are not CamelCase in which case it opens the tiddler which I don't want. 
<$appear show= {{!!title}} >
<$transclude mode="block"/>
</$appear>


Thanks,
-Rahul

Mark S.

unread,
May 23, 2020, 9:41:41 AM5/23/20
to TiddlyWiki
The wikitext form of invoking the macro is limited. But you can use the macrocall widget instead:

<$macrocall $name=details
sum=<<tiddler_variable_in_the_loop>> src={{{ [<tiddler_variable_in_the_loop>get[text]]}}} />

This is probably still not exactly what you want (the src will lose its original formatting). The next step would be to move the macrocall inside its own macro where substitution variables can be used.

Rahul Kashyap

unread,
May 23, 2020, 10:12:02 AM5/23/20
to TiddlyWiki
Hi Mark,

thanks for reply. I am not sure what would be the tiddler_variable_in_the_loop 

I tried with {{!!title}} which gives the title name but, without its content. Are there other way to get the tiddler_variable.

Best,
-Rahul

Mark S.

unread,
May 23, 2020, 11:23:14 AM5/23/20
to TiddlyWiki

tiddler_variable_in_the_loop was from your example. I assumed it contained the name of a tiddler. If not, then the example needs
to be re-explained.

Mark S.

unread,
May 23, 2020, 11:26:24 AM5/23/20
to TiddlyWiki

On Saturday, May 23, 2020 at 7:12:02 AM UTC-7, Rahul Kashyap wrote:

Rahul Kashyap

unread,
May 23, 2020, 11:34:30 AM5/23/20
to TiddlyWiki
Hi Mark,

Yes, I posted that question there as well. Mat asked me to start a new thread. I suppose this is proper thread? 

I tried Mat's latest solution as well but, it doesn't work. 

    tiddler_variable_in_the_loop was from your example. I assumed it contained the name of a tiddler. If not, then the example needs
    to be re-explained.

What I meant is when I use details macro as below, it works as expected but, when I call it from within list widget, it fails to get the tiddler name, it just gets it as string and doesn't transclude its content. 

<<details sum:"[[my_tiddler]]" src:"{{my_tiddler}}">>   //it works fine for any tiddler  but, doesn't work inside list widget if I use {{!!title}} in place of my_tiddler; also {{!!text}} doesn't work if I use it for src:"" argument. 

Best,
-Rahul




-Rahul

Mark S.

unread,
May 23, 2020, 12:27:06 PM5/23/20
to TiddlyWiki
This works:

<$list filter="[prefix[findme]]">
<
<details sum:{{!!title}} src:{{!!text}}>>
</$list>


Mat

unread,
May 23, 2020, 12:38:39 PM5/23/20
to TiddlyWiki
Mark S. wrote:
<<details sum:{{!!title}} src:{{!!text}}>>

That's very interesting! I didn't expect this to be allowed syntax since this is not allowed: <<details {{!!title}} {{!!text}} >> (...or is it???)

Thanks Mark and Rahul!

<:-)

Mark S.

unread,
May 23, 2020, 2:55:57 PM5/23/20
to TiddlyWiki


On Saturday, May 23, 2020 at 9:38:39 AM UTC-7, Mat wrote:
Mark S. wrote:
<<details sum:{{!!title}} src:{{!!text}}>>

That's very interesting! I didn't expect this to be allowed syntax since this is not allowed: <<details {{!!title}} {{!!text}} >> (...or is it???)


It seems to be allowed now. I'm thinking that maybe it didn't use to be?
Reply all
Reply to author
Forward
0 new messages