There is a similar question on here, but it's not quite what I'm looking for. We are upgrading from 3.5.3 to 5.1.x and we are converting all our user macros.
We currently have macros that start an HTML table and then one the ends that table. A third macro outputs a row for that table. This works fine in 3.5.3, but not in 5.1.x
I took the two macros that start and end the table and just created a wrapper macro that starts and ends the table and outputs $body, however, the macro that generates the row does not get rendered as HTML.
Is is possible to have a User macro that is called inside another User Macro (and therefore rendered as part of $body) to output as HTML?
I've found a workaround, which works for me - I don't know if it'll help you.
What this script does is every time the macro is called, it creates a table, a table body, and a table row with your stuff in it and then adds it to the bottom of the <tbody> element in your main table.
Confluence being Confluence, you can use its strength against it (some coding Jujutsu as it were) as it then strips out the empty table that you used to create the row. The result is a perfectly formed table as you wanted it. The only annoying thing is the JS that is being called each time.
I tried this, and it generates a series of separate tables for each row, so now the columns, for example, isn't the same width. It's a clever workaround, but I can't quite get it to work right. Is your table displaying as one solid table?
I guess I could set the cell width and remove the top and bottom margins... Still baffled why Confluence doesn't just render the HTML I provide, who cares if it's not wrapped in a <table> tag.
Yeah, it works fine for me. If it's generating separate tables for each then it sounds like the JS isn't working.
So in the first macro (which has no body), I have the following table:
<table> <thead> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody class="jhactbody"></tbody> </table>
(I've stripped out all data pertinent to my work).
In the second macro, after I've declared parameters etc, I have the second macro (which also has no body):
You then put one of the first macro in the page and then as many of the second macros as you like. They should be moved into the top table.
Did you try following the approach described by David Simpson (AppFusions) here: http://davidsimpson.me/2012/01/24/on-converting-wiki-markup-based-user-macros-for-use-with-confluence-4/
This certainly worked for me in Confluence 4. Not tried it in 5 yet, but I'd suggest giving it a go.
As @CharlesH says, try this approach http://davidsimpson.me/2012/01/24/on-converting-wiki-markup-based-user-macros-for-use-with-confluence-4/
I can confirm that it works for both Confluence 4.x and 5.x
It also removes the grunt work out of the process.
Thanks for the help, but that is showing how you call a user macro from within a user macro at the time of User macro development.
I'm talking about a user instantiating a user macro on a page that allows for a rendered body, and then in the body of that user macro they instantiate a different user macro that is supposed to render HTML.
When the body of the wrapping user macro is rendered it removes all the HTML markup from the output of the user macro begin called.
This is getting confusing to explain, here is a simple example of using macros to build a table that wraps rows. The row (User Macro 2) needs to output HTML, but when it's rendered as part of the body of User Macro 1, the HTML markup is stripped out.
User macro 1
## Macro has a body: Y ## ## @noparams <table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> $body </table>
User Macro 2
## Macro has a body: N ## ## @param paramcolumn1:title=Column1|type=string|desc= ## @param paramcolumn1:title=Column2|type=string|desc= ## <tr> <td>$!paramcolumn1</td> <td>$!paramcolumn2</td> </tr>
Can you indicate what the body processing should be for macro 1 please? As you've moved from 3.5 to 5, you'll see that the choices for this are different:
My gut feel is that you should be using the "Rendered" option, but it would be worth experimenting with the escaped and unrendered options if that doesn't work.
Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time! We're looking for people to participate in a remote 1-hr workshop...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs