Unknown macro: {alias}
Declare the following two velocity macros:
- you can declare the velocity macros below in the body of any user macro that needs to use them
- we declare it once, alone, in a confluence user macro called 'Render'. we call this confluence user macro from the dashboard. Once it executes once, confluence keeps the velocity macro '#render()' in memory until it is redeclared. (
after asking confluence support, this seems to be undocumented and may or may not be true in future versions of Confluence or Velocity) - if you declare the velocity user macros below in the appropriate .vm, you don't need to declare it in any user macro and only need to declare it once
#macro(trimp $xhtml) ## remove leading <p> and trailing </p> #if($xhtml.startsWith("<p>",0) && $xhtml.endsWith("</p>")) #set($len=$xhtml.length()-$generalUtil.convertToInteger(4)) #set($xhtml=$xhtml.substring(3,$len)) #end $xhtml #end #macro(render $wiki) #set($globalHelper=$action.getGlobalHelper()) #if($content)## i. e. we render a normal page #set($renderer=$globalHelper.getWikiStyleRenderer()) #set($context=$content.toPageContext()) #set($xhtml=$renderer.convertWikiToXHtml($context, $wiki).replaceAll("\n|\r","")) #else## we are e. g. in Global Template Preview #set($xhtml=$globalHelper.renderConfluenceMacro($wiki).replaceAll("\n|\r","")) #end #trimp(${xhtml}) #end #render($body)
Now you can use this syntax to render content:
#render($body)
#render("[test|CONFEXT:edit-include user macro]")
#set($wiki="{attachments}")
#set($html="#render($wiki)")
