How to insert a transclusion as a parameter of the tag Macro

I’ve read the documentation for $macrocall (MacroCallWidget) and thought it was simple (and it probably is) but sadly I haven’t been able to do it.
The situation is this, I have a field FieldX where I’m going to enter a tag name (which can change). I would like to put this value which can change as an argument of the Macro tag.
Something like this:

1  <<tag {{Tiddler!!FieldX}}>>

2  <$macrocall $name="tag" text={{Tiddler!!FieldX}}/>

In case 2, it defaults to the current tiddler. (As can be seen in the documentation for tag Macro)

  • How should I do?

The definition of the TWCore tag macro can be found here: $:/core/macros/tag

The parameter name used by the macro definition is “tag”, not “text”.

Your “case 2” should be written like this:

<$macrocall $name="tag" tag={{Tiddler!!FieldX}}/>
1 Like

It works, I assumed the structure of the macrocall was fixed and that it did not vary according to the macro. Thank you Eric!

One way to think of this is that the way we often invoke macros <<tag>> is a short form for convenience and allows unnamed parameters which are used in the order they are defined in the definition.

Just as the $transclusion widget is the long form of {{template}} {{||template}} or {{tiddlername||template}} the macrocall widget is the long form of calling macros.

  • Also remember because your macro may want a parameter called “name”, we need to use the '$name=macroname"
  • Thus we use the macrocall widget if we want to pass in parameters defined elsewhere
    • There are some tricks to using the short form for this but its simple to just revert to the macrocall widget.
  • There are new methods coming with TW 5.3.0
1 Like

Very interesting, crystal clear. Thank you!