Why can't I embed variable into TOC macro call using new 5.2.0 syntax?

I was answering someone elses’ question when I realized I had one of my own. According to the documentation release notes for 5.2.0, I should be able to embed a variable directly into a wikitext macro call.

First, it is now possible to nest macro calls within the parameters to other macros. For example:

<<mymacro arg:"""nested <<macro>> call""">>

So, this should work, right?:

<<toc tag:"""<<currentTiddler>>""" >>

When I put this at the top of “HelloThere”, I don’t get the expected TOC.

But it does transfer the name if I call my own macro like this:

\define echo(tag: "") I see tag: <<__tag__>>

<<echo  tag:"""<<currentTiddler>>""" >

Output:

I see tag: HelloThere

So I wonder what the real rules for embedding, and if it only works under certain conditions.

Thanks!

What this really means is that the wikitext macro call syntax wont break if it finds >> within a parameter, which was previously the case. So if you want to pass a macro like <<now>> within a parameter to another macro , knowing it will end up wikified, you can. This is what happens in your echo macro.

However the nested macro call is still passed as literal text. Therefore in the following you are passing the literal text <<currentTiddler>> as the parameter, not the value of currentTiddler.

<<toc tag:"""<<currentTiddler>>""" >>

Without having looked at the internals of the toc macro, I presume it needs the value for tag without it having a chance to get wikified, and gets the literal text <<currentTiddler>> and therefore does not work.

This change is not a replacement for needing to use the $macrocall widget to pass variable values as macro parameters.

1 Like

Perhaps try “{{!!title}}” as the parameter?