Hi,
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 com.atlassian.soy.renderer.SoyServerFunction as describe here: https://answers.atlassian.com/questions/89158/getting-a-soy-function-to-work-in-a-stash-plugin
Content of my .soy template{namespace MyPlugin.Blueprints.Simple} {template .macros} Hello {SoyMacrosFunction()} {/template}- 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.Cheers,Xavier
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} Hello {SoyMacrosFunction()} {/template}
See: https://developer.atlassian.com/display/CONFDEV/Writing+Soy+Templates+in+Your+Plugin (For templates that need parameters, these must be declared in JavaDoc style immediately before the template)
I hope I could help.
Cheers,
Raffy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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('com.xxx.confluence.macrodoc:macro-documentation-blueprint-item', function(wizard) { wizard.on('post-render.macroDocumentation', function(e, state) { fetchAndDisplayMacros = function() { $macrosContainer = $("#macroName"); $macrosContainer.append("<option value='Loading'> Loading...</option>"); $.ajax({ type: 'GET', url: AJS.contextPath() + '/rest/macro/1.0/macros', contentType:'application/json' }).done(function(macros) { $macrosContainer.empty(); 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() { clearMessages(); AJS.messages.error("#aui-message-bar", { body: "<p>Failed to fetch macros.</p>", closeable: true, shadowed: true }); }); }; // Fetch macros on page load fetchAndDisplayMacros(); }); });
Now it works perfectly but the use of SoyFunction still doesn't work !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.