macro.pngAllows creating XWiki macros through wiki pages and display existing wiki macros
Developed by

XWiki Development Team

0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise


XWiki 2.0M2+

Installable with the Extension Manager


The Wiki Macro Application allows you to convert any wiki page into an XWiki rendering macro. 

How to use

You simply need to add an object of type XWiki.WikiMacroClass to your wiki page, as shown below:


You should follow our wiki macro tutorial to learn more about writing wiki macros.

To see a list of wiki macros installed on your wiki, navigate to the XWiki.WikiMacros page 


Alternatively, you can also navigate to the XWiki.WikiMacroClass page:



There are several bindings that are available in the code content for the macro:

  • xcontext.macro.params: The list of all parameters passed to the macro, e.g. xcontext.macro.params.myparam would return the value for the myparam parameter in {{mymacro myparam="myvalue" ...}}.
  • xcontext.macro.content: The macro content
  • xcontext.macro.context: The Macro Transformation Context (MacroTransformationContext) which provides access to information such as the current XDOM Block (and thus access to all parent blocks too. For example a TOC macro would need to find all the Heading blocks), the syntax of the content of the macro, whether the macro is inline or not, etc.
  • xcontext.macro.result: This is an output parameter into which the result of the macro can be stored if you wish to directly return the desired list of rendering blocks without having to render them first to let them be parsed back by the macro transformation. The benefits are that it could be a lots quicker and most of all it means supporting syntaxes which does not provide any renderer. It also makes it possible to generate some XDOM which is impossible to write in some syntaxes.
  • xcontext.macro.doc: The com.xpn.xwiki.api.Document instance of the document in which the macro is defined.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki


Dependencies for this extension (org.xwiki.platform:xwiki-platform-rendering-wikimacro-ui 9.6):

Created by Asiri Rathnayake on 2009/07/26 21:21

Get Connected