hi,
i want to build a dynamic table (with costumizable amound of tablerows). For that I want to nest macros.
the outter macro rn:
<table>
<tr>
<th>header1</th>
<th>header2</th>
</tr>
$body
</table>
the inner macro rn:
<tr>
<td>cell1</td>
<td>cell2</td>
</tr>
So why not write it as single user macro with parameters to construct the size table you want with the appropriate variables?
You could for example, have the cell values as a comma-separated list in the macro body, that the macro can then parse.
A single macro is probably going to be easier to get working.
I already thougt about that, but it does not fit my case. At the end I want a dynamic table with enum parameters like
## @Param Example1:title=Example1|type=enum|enumValues= cell1,cell2,cell3,cell4
in the cells.
I dont think that this is possible with only one macro isn´t it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well I know of no limit on the number of parameters. But what I was suggesting is a comma-deliminated set of values that you place in the body of the macro. Then you can parse that string to get your values. You can even make it easy by have comma separate values, and semicolons separate rows/sets of values. Then you can have a data set as large as you want.
With Velocity you have access to a number of Java string methods, for example .split that you can use to parse a long string in the a list.
OR if you are lazy like me, you use a CSV file and import the values from an attachement. Fortunately, Davin Studer has written an excellent pair of articles on a user macro that builds a table from a CSV file. Here is part one:
A-User-Macro-to-Create-a-Table-From-an-Attached-CSV-File-Part/ba-p/738757
You could modify it so that rather than reading a CSV list from a file, it could be read from $body to make it easier.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
thank you for your quick answer.
My problem is, that the output of nesting the macros is not an table.
The output looks like this
I think the code of the inner macro is rendert wrong sothat the output of the inner macro is:" cell1 cell2 " instead of "<tr><td>cell1</td><td>cell2</td></tr>"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see - I get the same - But I need some time for investigation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may need to play with the Macro Body Processing settings. I think you may need to set one or both to unrendered.
When you are experimenting, it might be useful to use the browser inspect function to what is actually being output.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.