How can a User Macro discover all the parameters passed to it

Brian M Thomas July 2, 2018

Is there any way to access the full set of parameters passed to a User Macro without knowing them beforehand?

I am trying to create a general-purpose macro that can call any of several other macros or templates, and I don't see any way that I can just send all of the passed parameters on to another instead of having to check for the existence of each of any number of possible parameters.

I have also long desired this ability for debugging purposes, but I have never found it.

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Chii
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2018

Unfortunately, user macros needs to know the parameters a head of time. 

 

The parameters list is only accessible in a XHTML macro, which requires java code and is  not user editable.

Brian M Thomas July 18, 2018

Thanks.  I was all but certain of that, having pored over the documentation and tried every trick I could imagine, but wanted to be sure.

What I needed is to migrate a client's content that uses a Mediawiki feature that renders a template in the text of a page using parameters passed to it.  Confluence's templates and blueprints only work when creating a new page, so that's out, but a User Macro might be able to accomplish the same by setting Scaffolding variables and invoking the Scaffolding plugin's live-template macro or, at the worst, creating a dynamic call to the Scaffolding plugin's REST API.  In either case, I need to know the names of the parameters so as to set them appropriately.

Looks like I'll have to see what the plugin vendor can tell me about invoking a live template with parameters.

Abdullah AlThawr July 18, 2018

Hello @Brian M Thomas, this is one of Scaffolding Plugin developers who work at ServiceRocket. Would you mind providing me more context so that I can help you out? what are the parameters you want to know the names of? Feel free to open a support ticket with us and share more context over there and we will assist.  

Brian M Thomas May 30, 2019

Abdullah:

Sorry for the lengthy delay; I only saw this reply just now.

What I needed was an equivalent to the MediaWiki template feature that allowed the content of a template page to appear in another with values specified by the invocation.  Such templates are like User Macros and I decided to create one User Macro for each of the client's templates, but it turns out that neither User Macros nor Scaffolding was available to my client.  

And I simply don't understand your second question at all:  Since the whole problem is that I don't know what they are, I can't tell you which ones they are.  Regardless, the desire for a User Macro that could learn which parameters it was invoked with was part of my attempt at a general macro that could be invoked with the name of a template page and parameters specific to that page to fill placeholders in it.  It would allow a direct conversion of each invocation to a macro call with all the same parameters instead of distinct User Macros to replace each template.

I briefly considered the live-template macro as some kind of a workaround, but I don't think that it can be adapted to do what is needed since it introduces an intermediate edit mode that isn't needed and -- worse -- it has a fixed parameter list.  

So unless you have in mind the crafting of a new kind of template macro with a dynamic parameter list, I don't think there's much you can do for me.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events