General Actions:
XWiki Platform 1.9 introduced the possibility to filter the Velocity macro content before and after the Velocity Engine execution.
You can set the default filter to use in xwiki.properties by the setting the property macro.velocity.filter. You can also set the filter to use directly when writing the macro by setting the macro filter parameter as you can see in the previous table.
By default the provided filters are:
Do nothing, it's what happened before XWiki Platform 1.9
Remove all first whites spaces of lines to support source code indentation without generating whitespace in the resulting HTML.
Is the same as
The goal is to make the velocity script more readable by supporting indentation and code organization with empty lines and putting if/else/.. on their own lines.
This is done by applying a html like cleaning on white spaces and new lines meaning that any group of spaces/new lines is replaced by a space except for some specific use cases which are:
So for example:
will generate
instead of
The filter inject the mapping $sp and $nl to be able to force a space of a new line (like putting a <br/> in html).
The velocity macro content filter are xwiki components so to add one you just need to implements VelocityMacroFilter component interface and set the right component attributes. See WritingComponents for more details on XWiki components.