Content Macro

Last modified by Admin on 2024/05/19 06:46

cogAllows entering content in any of the supported Syntaxes
Developed by

XWiki Development Team

0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard


XWiki 4.2M3+

Installable with the Extension Manager


Allows to enter content in any of the supported Syntaxes and thus allows to have content written in various syntaxes.


{{content syntax="<syntax id>" source="script:myvariable"}}
...content written in <syntax id> syntax...


  • syntax: The technical identifier of the syntax in which the content is written. For example: xwiki/2.0, xwiki/2.1, confluence/1.0, html/4.01, xhtml/1.0, markdown/1.0, etc. Check the "Input" column of the supported Syntax table for the full list of supported syntaxes. XWiki 15.1+, 14.10.5+ Fallback on current syntax if not indicated
  • XWiki 15.1+, 14.10.5+ source: indicate the reference of a source to use to get the content instead of passing it as macro content


XWiki 15.1+, 14.10.5+  

The format of the reference of the source is <source type>:<reference>.

The content macro currently supports the following types of sources:

  • string: the reference is the content to highlight ({{content source="string:**wiki content**"/}}), it's also the default type when none is provided ({{content source="**wiki content**"/}}
  • script: the reference is the name of a script binding in the current script context, using it requires SCRIPT right.
    #set($myvar = '**wiki content**')
    {{content source="script:myvar"/}}

Add support for a new source type

To add support for a new type of source, you need to provide a component implementing role org.xwiki.rendering.macro.source.MacroContentWikiSourceFactory and having as role hint the prefix to use in the source reference.

public class MyMacroContentWikiSourceFactory implements MacroContentWikiSourceFactory
   public MacroContentWikiSource getContent(MacroContentSourceReference reference, MacroTransformationContext context)
       throws MacroExecutionException
       return new MacroContentWikiSource(reference, getContent(reference.getReference()), getSyntax(reference.getReference()));

{{code source="mytype:myreference"/}}


This is in **bold**

{{content syntax="confluence/1.0"}}
This is *bold* too!

Results in:


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 for this extension (org.xwiki.rendering:xwiki-rendering-macro-content 16.3.1):

Get Connected