Need help with passing currenTiddler to toc-selective-expandable

Hi, I am trying to show the a list of contents at the top of each tiddler. I am editing the $:/core/ui/ViewTemplate/body tiddler to accomplish that. I can’t figure out how to pass the currentTiddler as an argument to <<toc-selective-expandable>>. I want the root of the tree to be the current tiddler for every tiddler.

Currently this is what I have :

 More:
<$set name="variable" value=<<currentTiddler>>>
	<$let toc-open-icon="$:/core/images/fold-button" toc-closed-icon="$:/core/images/folder">
	<div class="tc-table-of-contents">
	<<toc-selective-expandable <<variable>>>>
	</div>
	</$let>
</$set>

Any help would be greatly appreciated.

[Edited] To wrap <<toc-selective-expandable>> in single backticks, so it is readable eg “<>” is not.

Not sure if this is the only problem, but one thing I notice is the use of <<variable>> inside a different <<...>>, which is invalid syntax.

You will need to call the “toc-selective-expandable” macro using the <$macrocall> widget or the <$transclude> widget. The first one, $macrocall, may be easier to understand intuitively (just from the name), though it is deprecated as of version 5.3.0. The other one, $transclude, will work similarly; macros are a kind of variable, so you can use the “$variable” attribute, like so:

<$transclude $variable="toc-selective-expandable" tag=<<variable>>/>

If you do it this way, you can probably also use <<currentTiddler>> instead of <<variable>> and then you might not even need the set widget.

There is a safer way to accomplish this than by editing $:/core/ui/ViewTemplate/body; you can instead make a separate tiddler containing the table of contents, and add the tag $:/tags/ViewTemplate to that tiddler, and add a field list-before into which you enter $:/core/ui/ViewTemplate/body and that will make it appear above the body of the tiddler (but below the title, toolbars, etc.). See https://tiddlywiki.com/#Customising%20TiddlyWiki’s%20user%20interface for more details (though you it may involve a little digging into the System Tags link there to find what explains this specifically).

That worked for me. Thanks!