Hi,
I already had a look at these questions, without a clear answer for my issue:
https://answers.atlassian.com/questions/24391/replacement-for-renderconfluencemacro
I am developing a Confluence plugin for the latest version 4.3-RC1 (the question should apply to all 4.* Confluence versions). Rendering the Macro inside the Wysiwyg-Editor works fine. However, I can't find a way to embedd the macro inside of my .vm template. In previous Confluence versions, this was achieved by the #renderConfluenceMacro function. I can't get this function working with my xhtml-macro, I only get the error "unknown macro".
However, rendering a built-in Confluence macro like "loremipsum" with #renderConfluenceMacro("{loremipsum}") works fine.
So, how can I render a macro within a .vm template in Confluence 4.*? In atlassian-plugin.xml, my macro is defined as follows:
<xhtml-macro name="scevents" class="de.scandio.confluence.plugins.sc.events.macros.Event.TeaserListMacro" key="scevents">
<parameters> <parameter name="limit" type="string" /> </parameters> </xhtml-macro>
I also tried the approach using the XhtmlContent Interface as specified in one of the above questions:
$xhtmlContent.convertWikiToView("{scevents}", null, null)
The $xhtmlContent is a DefaultXhtmlContent instance. This call just gives me a NullPointerException using the two null-parameters.
I appreciate any help, since this is a fairly important plugin for us.
Regards,
Felix Grund [Scandio GmbH]
Hi Felix,
XHTML Macro s can not be rendered with $action.getHelper().renderConfluenceMacro("...").
To render your macro, you must inject the XhtmlContent-Interface in your action.
After that, you can render the macro with following call:
$xhtmlContent.convertStorageToView("<ac:macro ac:name=\"Example Macro\" />", null)
When you use that in velocity template the return is a escaped string.
In my case i add a new function to my action called getMacroAsHtml() and put an @HtmlSafe above.
So i get an unescaped html string.
I hope that this comment proves helpful.
Regards,
Markus Weigelt [Communardo Software GmbH]
Hi Markus,
thank you very much for your reply. When I was searching for a solution to my problem, I ended up migrating my macro according to this guide. At first sight, however, your solution seems to be more elegant. I'm going to look at it again when the issue occurs next time.
Regards,
Felix [Scandio GmbH]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.