user macro resolution order

When I put a {userMacro} inside a [link to {userMacro}] it doesn t get resolved at the right time. Confluence wants to create a page, though the link exists.


1 answer

I would suggest you modify the userMacro in question to just generate the link rather then the page name.

Thanks, I did just this, but isn t the resolution order violation a major bug?

Hi Guenter,

I'm not so sure this is a bug, major or minor. The output from a user macro could be anything, not just text. I guess Confluence is playing it safe and saying that a text string is expected between [ and ], hence it doesn't parse the contents for any user macro processing.



Well, thanks, my opinion is that expressions should be parsed in the right order, no matter what - and they could throw an error still if it evaluates to something the browser can t handle.

The currents behavior fits well with Confluence s other inconsistencies.

@Guenter - if you feel strongly, I suggest you raise a well-worded ticket here, and make your case for the Atlassian team to address. If feasible and highly desired they usually will deliver.

@Guenter - I would also be interested to know what version of Confluence you are using.

Good idea, Daniel!
5.1.3, so I need to re-test how much this applies to a version > 4. We were at 3.5.9 until recently.

Just tested this quickly and saw that a Link > Advanced [link to {userMacro}] renders an internal server error.

Needa rethink the whole dynamic link thing.

As I couldn t find a way to put a macro inside a link I had to code the whole thing as XHTML:

## @noparams
#set($len1 = $space.key.length() - 2)
#set($len2 = $space.key.length() - 1)
#set($sub0 = $space.Key.substring($len2))
#set($sub1 = $space.Key.substring($len1, $len2))
#set($sub2 = $space.Key.substring($len1, $len2))
#set($sub3 = $space.Key.substring($len2))
<ac:link> <ri:page ri:content-title="page title part 1 #if ($sub0 == "0")$sub1#else$sub2.$sub3#end page title part 2" ri:space-key="SPACEKEY"/> </ac:link>

As I got no answer to the I had to put the argument expressions into variables.


Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

94 views 0 5
Read article

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