Broken <tr> with macro calls

64 views
Skip to first unread message

Iain

unread,
Feb 21, 2018, 10:17:50 PM2/21/18
to TiddlyWiki
I'm trying to construct a tabulated listing of tiddlers using the following template. In the <tr> element, "order" is an attribute, and it's value XXX is the tiddler's position in the title list (not shown in example).

<$list filter="filter goes here">
  <tr order="XXX">
    <!-- row contents here -->
  </tr>
</$list>

As I've discovered, tiddlywiki macros don't do simple text substituion at all, so doing something obvious like

\define makerow(i) <tr order="$i">

<$list filter="filter goes here">
  <$macrocall $name="makerow" i=<<XXX>> />
    <!-- row contents here -->
  </tr>
</$list>

doesn't work because the substition works fine, but the macro output then seems to be rendered into the DOM tree as  a <tr order="1"></tr>, but NOT wrapped around my row contents (and the </tr> in the source is now an orphaned end element).

Can anyone instruct me on how I can produce <tr> elements so they get the correct attribute value and wrap my row contents - the row contents in the sample is quite complicated, so I suspect it'll break tiddlywiki if the answer is to move the lot up into the macro.

Cheers, Iain

Mark S.

unread,
Feb 21, 2018, 11:30:00 PM2/21/18
to TiddlyWiki
As a starter, there's an error in your macro. It should be "$i$", not "$i".

Good luck!

-- Mark

Stephan Hradek

unread,
Feb 22, 2018, 5:14:35 AM2/22/18
to tiddl...@googlegroups.com
Why not let the macro return the full row?

\define makerow(i)
<tr order="$i$">
<td><<currentTiddler>></td>
</tr>
\end

\define XXX() 1

<table>
  <$list filter="[tag[ActionWidgets]]">

    <$macrocall $name="makerow" i=<<XXX>>/
>
 
</$list>
</
table>

Example was tested on Tiddkywiki.com

Iain

unread,
Feb 22, 2018, 6:59:18 AM2/22/18
to TiddlyWiki


Thanks for the advices. I ended up rewriting and having the macro generate the complete <tr>. Turned out to be a better solution anyway, making my whinging a little hollow :)

TonyM

unread,
Feb 22, 2018, 5:26:31 PM2/22/18
to TiddlyWiki
Ian,

In some similar work in the mymenus plugin I simply used two list as follows;

Psuedo code

<Table>
Add th here
<$list filter
<tr>
<$list filter
<td><<detailsmacro>><td>
</$list>
</tr>
</$list>
</Table>

Leaving responcibility for table formatting out of a macro allows that macro to be used in otherways as a global macro.

And also if you want variables and fields to work inside html tags look at evans formula plugin as you can use it to programaticaly alter html tags

Eg

<tr order=(=yourcalc=) >

Reply all
Reply to author
Forward
0 new messages