Last modified by Sergiu Dumitriu on 2010/06/03

Question How are macros used? I tried to use the #warning("Hello World") macro but all I got was the output "#warning("Hello World")".
Answer There are two kinds of macros, velocity macros and syntax macros, and there are two main document syntaxes available, xwiki/1.0 and xwiki/2.0.

  • velocity macros, like #warning, can be used in 1.0 documents directly
  • velocity macros must be placed inside a {{velocity}} block in 2.0 documents to work
  • syntax macros, like {{warning}}, can only be used in 2.0 documents
Since xwiki/2.0 is the default syntax now, to use a velocity macro you should write something like this:

#warning("Something is wrong")

Note that for this particular case, there's also a syntax macro, so you should write:

{{warning}}Something is wrong{{/warning}}
Created by DieterStrecker on 2007/07/17

Get Connected