How do I access Confluence macro parameters within a custom migrator (used to migrate to an xhtml macro)?

I have a 3.x macro that requires (un-named arguments) that is to be migrated to a 4.x xhtml-macro.

The migration works but the parameters in the xhtml-macro are not populated.

Old macro example:

{myMacro:arg1|arg2}

I try to get "arg1" and "arg2" above using this:

(String) macroParams.get("0") and (String) macroParams.get("1")

It doesn't appear to work. Ideas? :-)

2 answers

1 accepted

This widget could not be displayed.

Within the migrator:

final Map<String, String> macroParams = macroDefinition.getParameters();

final String defaultValue = macroDefinition.getDefaultParameterValue();

defaultValue = the first argument (arg1) in {myMacro:arg1|arg2}

macroParams.get("1") = the second argument (arg2) in {myMacro:arg1|arg2}

I believe this is the correct answer. If someone knows better, please respond! Thanks.

This widget could not be displayed.

Macros have a "Default" parameter, i.e. one whose key is an empty string (getParam("")) while, it appears, xhtml- macros use "0" (getParam("0")). Macro params following the default one start at "1" (getParam("1")). I believe this is the correct answer. If someone knows better, please respond! Thanks.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

194 views 18 7
Join discussion

Atlassian User Groups

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!

Find my local user group

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

Groups near you