Confluence Blueprints: How to display the list of existing macros in the dialog-page ?


I'm trying to develop a Blueprint that will include in the rendered page a macro choosen by the user in a list or by auto-completion

I know how to do it in Java (using com.atlassian.confluence.macro.browser.MacroMetadataManager)

But I don't know how to create a custom list in soy template with dynamic content (provided by a Java class ?)

I spent a lot of time on this forum:

1) I tried to implement as describe here:

  • Content of my .soy template
    {namespace MyPlugin.Blueprints.Simple}
    {template .macros}
  • but it always return error: Uncaught Error: atlassian-plugin.xml blueprint wizard points to a non-existent Soy template 'MyPlugin.Blueprints.Simple.loop'.
  • If I remove instruction {SoyMacrosFunction()}, the template works

2) I tried to use classes autocomplete-multiselect in my soy template. It doesn't work

Any adivse would be much appreciated.

2 answers

1 accepted

1 vote
Answer accepted

My previous comment was not recognized by the Atlassian email robot. So I answer to my own question:

I'm now able to display the list of existing macros in the dialog-page of a Blueprint. But I used a REST API in conjunction with javascript hook as described in my comment. I was not able to implement a SoyMacroFunction

Hi Xavier,

please try to add a SoyDoc before your template:

{namespace MyPlugin.Blueprints.Simple}
*  This is a SoyDoc example
{template .macros}

See: (For templates that need parameters, these must be declared in JavaDoc style immediately before the template)

I hope I could help.



There is already a SoyDoc in my .soy file but I didn't copy it my this example.

Anyway, I changed the way of doing:

I created a REST API based on this tutorial to retrieve all installed Confluence macros and I added the following code in the javascript file associated to my blueprint based on this tutorial

Confluence.Blueprint.setWizard('', function(wizard) {
    wizard.on('post-render.macroDocumentation', function(e, state) {
	    fetchAndDisplayMacros = function() {
	        $macrosContainer = $("#macroName");
	        $macrosContainer.append("<option value='Loading'> Loading...</option>");
	            type: 'GET',
	            url: AJS.contextPath() + '/rest/macro/1.0/macros',
	        }).done(function(macros) {
	            for (var i = 0; i < macros.length; ++i) {
	            	var macro = macros[i];
	                $macrosContainer.append("<option value='" + macro.macroName+ "'>" + macro.titleText + "</option>");
	            if ($macrosContainer.find("option").length == 0) {
	                $macrosContainer.html("<p>No macro have been defined.</p>");
	        }).fail(function() {
	            AJS.messages.error("#aui-message-bar", {
	               body: "<p>Failed to fetch macros.</p>",
	               closeable: true,
	               shadowed: true
	    // Fetch macros on page load
Now it works perfectly but the use of SoyFunction still doesn't work !!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

282 views 2 11
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