It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can you nest user macros in Confluence and edit $body in the nested implementation?

Jerod Venema Dec 30, 2017

I'm building up documentation that shows examples of an SDK in multiple languages. Each language gets a tab. So we end up with a template that looks like this:

<tabs>

   <tab>

     <language>

     <code>

   </tab>

</tabs>

 

...with a repeat on the "tab" section obviously, for each language we support. The issue is that I need to have editable content (that's extensive - a single-line textbox is not enough) in each <code> area. So multiple rich-content areas. I'd love to have my macro spit out (for example) a panel for each language or something.

 

Here's my template as it exists right now. This technically works, but you'd have to edit your code in a single-line text field - obviously not usable.

 

## Macro title: Code Tabs
## @param csharp:title=C#|type=string|desc=C#
## @param java:title=Java|type=string|desc=Java
<ac:structured-macro ac:name="sp-tabs">
<ac:rich-text-body>
<ac:structured-macro ac:name="sp-tab">
<ac:parameter ac:name="title">C#</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:name="code">
<ac:parameter ac:name="language">c#</ac:parameter>
<ac:plain-text-body><![CDATA[ $!paramcsharp ]]></ac:pain-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name="sp-tab">
<ac:parameter ac:name="title">Java</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:name="code">
<ac:parameter ac:name="language">java</ac:parameter>
<ac:plain-text-body><![CDATA[ $!paramjava ]]></ac:pain-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>

</ac:rich-text-body>
</ac:structured-macro>

Is there a way I can just let that <code> macro render as a sub-editor in my macro somehow?

1 answer

0 votes
Bill Bailey Community Leader Dec 30, 2017 • edited

I don't think so. $body (in place of, e.g., $!paramcsharp) is what you want to give you an editing block (in page edit view), but you need three blocks. I am not aware of any editing block capability inside the macro browser/IF.

BUT, if you create your own markdown, you could have an editing block on the page, and have all three code blocks in a single editing block, THEN parse them into each of your parameters. That is how I would do it. For example

!CSHARP

<some code>

!JAVA

<some code>

!VTL

<some code>

Of course, you would need to create a man page to explain how to properly enter the source in the body.

Jerod Venema Jan 01, 2018

Not a bad plan. I'd need to have a way to force the $body to be plain text though, or it'll end up giving me pre-parsed html content, will it not?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

1,249 views 7 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you