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.

Solution?
Thx
G.

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.

Regards,

Charles

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.
G.

@Guenter - if you feel strongly, I suggest you raise a well-worded ticket here, https://jira.atlassian.com 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.
Thanks

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 https://answers.atlassian.com/questions/205782/velocity-expression-as-argument/205824 I had to put the argument expressions into variables.

G.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

25,027 views 2 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