Wiki Macro Store
Defines the ability to store macros into wiki pages |
Type | JAR |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Bundled With | XWiki Standard |
Description
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, check the Help Center, the Syntax Help or navigate to the XWiki.XWikiSyntaxMacrosList page.
Alternatively, you can also navigate to the XWiki.WikiMacroClass page:
Bindings
There are several bindings that are available in the code content for the macro.
Starting with $wikimacro:
all of them are available through- wikimacro.parameters: The list of all parameters passed to the macro with value converted to the given type, e.g. wikimacro.parameters.myparam would return the value for the myparam parameter in {{mymacro myparam="myvalue" ...}}.
- wikimacro.content: The macro content
- wikimacro.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. This binding is not set if the wikimacro is executed asynchronously. For example to know if the macro is being rendered in an inline context, use wikimacro.context.isInline().
- wikimacro.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.
- wikimacro.doc: The com.xpn.xwiki.api.Document instance of the document in which the macro is defined.
- wikimacro.descriptor: The macro descriptor. It returns a org.xwiki.rendering.macro.descriptor.MacroDescriptor Java object. For example if you wish to test if the macro supports the inline mode, you can use: wikimacro.descriptor.supportsInlineMode().
Some bindings are also available through $xcontext.macro but they are now considered as deprecated:
- xcontext.macro.params: The list of all parameters passed to the macro, e.g. xcontext.macro.params.myparam would return the String 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.
- xcontext.macro.descriptor: The macro descriptor. It returns a org.xwiki.rendering.macro.descriptor.MacroDescriptor Java object.
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).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Dependencies
Dependencies for this extension (org.xwiki.platform:xwiki-platform-rendering-wikimacro-store 16.8.0):
- org.xwiki.platform:xwiki-platform-rendering-wikimacro-api 16.8.0
- org.xwiki.platform:xwiki-platform-oldcore 16.8.0
- org.xwiki.platform:xwiki-platform-wiki-default 16.8.0
- org.xwiki.platform:xwiki-platform-rendering-parser 16.8.0
- org.xwiki.platform:xwiki-platform-component-wiki 16.8.0
- org.xwiki.platform:xwiki-platform-rendering-async-default 16.8.0
- org.xwiki.rendering:xwiki-rendering-api 16.8.0
- org.xwiki.rendering:xwiki-rendering-transformation-macro 16.8.0