Refactoring a macro to pull out a submacro: syntax question

I have a relatively simple macro to write a table based on a number of tiddlers. I would like to break it down into a macro that writes the shell (<table> and <thead> as well as their end tags) and calls another macro that writes the <tbody> in the middle, so that I can reuse the latter macro in other contexts. But I’m flustered once again by a syntax problem: How do I pass the outer parameter to the inner one:

\define board-members(board)

<table>
  <thead> <!-- ... --> </thead>
  <!-- ******************************************************************** -->
  <$transclude $variable="board-members-body" board=????? />
  <!--            *****  What goes here? -------------^  *****              -->
  <!-- ******************************************************************** -->
</table>

\end

I’ve tried various syntaxes (<<board>>, <__board__>, {{{ <<board>> }}}, {{{ <__board__> }}}, and others, with and without quotes), but it’s just guessing, and not coming up with something that works. If I hard code the value as a string, the output is right for that given value, but it ignores the outer parameter, of course.

Is there a simple solution that will work here?

This is some heavy modification of an existing wiki, written in 5.2.3. If this would be better written with functions/procedures from 5.3.0, let me know, and I will try to update. Either way, I would still like to know if I’m missing some simple way to do this, or am dealing with a more substantial misunderstanding of macros. (It’s happened before!)

In a v5.2.3 wiki the transclude widget does not have support for transcluding variables.

Try this instead:

<$macrocall $name="board-members-body" board=<<__board__>> />

See https://tiddlywiki.com/#MacroCallWidget

The parameter to the outer macro is available within its scope as a variable with double underscores wrapping the parameter name. Other than that you use it as you would any other variable.

Oh, of course. I went for macrocall first, saw the deprecation warning, and just moved on to trying this with transclude. I should have noted the deprecation version…

Still, if I do move up to 5.3, is this behavior better created by functions/procedures?

Thank you for your help!

@Scott_Sauyet you could do this via a transclude rather than in a macro, or transcluding in a macro.

  • I would encorage an upgrade to the latest tw version, when possible (perhaps with 5.3.0 wait for 5.3.1) and testing any wiki so your wiki does not fall behing in versions. Being forced to upgrade may be harder if you have to upgrade more versions. Remember backawards compatibility is tiddlywikis practice.

I have tested it but $macrocall works in 5.3.+ for both define and procedure pragma, but internaly the parameters must follow the rules.

  • Although depricated, I am tempted to keep using macrocall unless I need a feature of the transclude $variable.

When using the macrocall as @saqimtiaz the “board” parameter can also be accessed before 5.3.x with

<$macrocall $name="board-members-body" board="$board$" />

or

<$let board="value">
<$macrocall $name="board-members-body" />
</$let>

and inside the macro

<$macrocall $name="board-members-body" board=<<board>> />

or

<$macrocall $name="board-members-body" board="$(board)$" />

If you are interested you could “generalise your macro further” so you provide both the board and the ‘board-members-body’ as a parameter.

Far more posibilities become possible in 5.3.x and as our use matures expect even better solutions.

  • A custom widget
    • Using the slot and fill widgets
  • Using $parameters
  • Using the genesis widget for <table>