I am wondering if there is a good way to access the title of the tiddler which invoked the current transclusion, but that isn’t necessarily the currentTiddler
.
Background: I use a decent number of custom toolbar buttons, so I currently have a procedure which I import into my new button tiddlers which lets me avoid duplicating the same code across every single one.
\whitespace trim
\procedure toolbar-button(button-tiddler,button-actions)
<$button actions=<<button-actions>> tooltip={{{ [<button-tiddler>get[description]] }}} aria-label={{{ [<button-tiddler>get[caption]] }}} class=<<tv-config-toolbar-class>>>
<% if [<tv-config-toolbar-icons>match[yes]] %>
<$transclude $tiddler={{{ [<button-tiddler>get[icon]] }}}/>
<% endif %>
<% if [<tv-config-toolbar-text>match[yes]] %>
<span class="tc-btn-text"><$text text={{{ [<button-tiddler>get[caption-text]] }}}/></span>
<% endif %>
</$button>
\end
My toolbar button tiddlers then simply look like this:
\import [the above tiddler defining the procedure]
\procedure actions() [actions go here]
<$transclude $variable="toolbar-button" button-tiddler=<<thisTiddler>> button-actions=<<actions>>/>
This is the reasonably neat and tidy, but the perfectionist in me can’t help but wonder: Is there a way to access the name of the tiddler which transcludes the toolbar button procedure from within the procedure itself, e.g. as a default value for the button-tiddler
parameter, rather than having to pass it as a parameter using thisTiddler
in every button tiddler?
To be clear, my current method works well enough, but I am wondering if anyone with a deeper understanding can answer my question, just for my own education.
Thanks for reading!