The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add user macro into a plugin

koushikkothagal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2019

I have a user macro created in the Confluence Admin UI. How do I add it to a Confluence plugin?

I tried creating a macro using the Confluence tutorial, but the tutorial shows how to return a String as HTML. I even tried rendering my user macro .vm file in the plugin using Velocity helpers, but I don't seem to have the same context (no $content for example).

 

Please help!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
koushikkothagal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2019

Solved the problem using the context passed into the execute method:

public String execute(Map<String, String> parameters, String body, ConversionContext context) throws MacroExecutionException {

PageContext pageContext = context.getPageContext();
contextMap.put("content", pageContext.getEntity());

}
TAGS
AUG Leaders

Atlassian Community Events