velocity

Last modified by Lucas Charpentier on 2026/10/27 10:30

Audit

Macro ID
velocity
Source
XS
Type
Generator
Classification reason
Generator, like the other script macros: the output is what the script computes, far from the code typed in the content, which the reader never sees. The parameters only change how the script runs and how its output is processed.
Status
Reviewed
Criteria version
15.20
XWiki version
18.8.0
Audit date
2026-10-20
Auditor
Compared macros
groovy python

Sources

Where to gather the information the criteria are checked against, see Gather the sources.

SourceWhat it givesUsed forWhere
DocumentationParameters, default values and examples, including the most common exampleL2, L3, and the criteria measured with the most common examplehttps://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity%20Macro#HUsage
Source codeHow the macro declares its parameters and content: types, groups, features, advanced and hidden flags, constraints, content type, inline supportC4, C5, C7, C8, C9, C13, E4, E6https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-18.8.0/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-velocity/src/main/java/org/xwiki/rendering/internal/macro/velocity/VelocityMacro.java
Macro descriptorWhat the Edit Macro dialog is built from, on design.xwiki.orgD1, D2, C1 to C9, E4Descriptor, list of macros with their categories
TranslationsThe name, description and parameter names in each languageD1, D2, D4, C1l10n.xwiki.org
Uses in XWiki pagesHow XWiki itself uses the macro, a realistic example when the documentation has noneL3, C2, C3, C6, C8, C9Search the xwiki organization on GitHub
Compared macrosThe audits of the macros of the same typeL1, D3groovy, python
Other sources specific to this macro
CriterionResultNotes
D1 wordingOK"Velocity" is the name of the technology, and the macro is audited as a developer macro, in the Development category, so the name is fine. The French and German names are "Velocity" too.
D2 summaryOK"Executes a Velocity script." says what the macro does, and for a generic script macro this is enough, like "Fetches information from a JIRA server". It does not say that the output of the script is inserted in the page as wiki syntax, which the output and wiki parameters tell.
D3 categoryOKonly Development, where users look for a script macro, like html and groovy.
D4 quick-actionOKQuick Actions finds the macro first for "velocity" and in fourth place for "script", among Script, Groovy, Python and php. "velocity script", "code", "template" and "run code" do not find it. The French and German names are the same as the English one, and no other language has a different name, so only the English name, the ID and one synonym are checked. A technical macro named after its technology is OK even when few synonyms find it, like html.
L1 consistencyOKcompared with groovy and python, the other script macros, which also take a mandatory script as content: the Quick Action opens the Edit Macro dialog with a required Content text area, and the macro declares inline support. The wiki parameter defaults to true, like them, since the output of a script is wiki syntax.
L2 doc-parametersKOthe parameters are documented only on the legacy extensions.xwiki.org page, https://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity%20Macro, not in the new documentation. On that page only filter is a documented parameter, with the default indent. The content and jars are not documented, and output and wiki are only mentioned.
L3 doc-exampleKOminor: Example 3 of the documentation, a foreach loop over a list of words, shows the plain use and renders "Some velocity code", so it is used as the most common example. Example 1 is a syntax template with placeholder values that renders nothing, and Example 4 contains the placeholder "... some condition..." and fails with "Encountered ..", so the editor cannot reproduce it. In XWiki itself, the plain {{velocity}} is the most frequent call, then output="false".
I1 patternOKcompared with the reference generator, children. The Velocity Quick Action opens the Edit Macro dialog with an empty Content text area, and the macro needs its script to do anything, so the dialog is OK, like include and the other script macros.
I2 zero-configOKsubmitting the dialog with an empty content keeps it open with no message, the generic behavior of the dialog for a mandatory value. A {{velocity/}} written in the source renders nothing, with no error, which is the expected result of an empty script.
I3 instantN/AN/A for a generator. The Quick Action opens the Edit Macro dialog with an empty Content text area, see I1.
I4 cursorN/AN/A for a generator. After submitting the dialog, the macro widget is selected, and the script can only be changed through the dialog.
I5 focusOKthe content, the script, is the only mandatory parameter: the Edit Macro dialog shows its text area first, with the focus in it, and every field is visible without scrolling.
E1 wysiwygOKwith a script that prints text, the editor shows its rendered output, "Some velocity code" for Example 3, the same as view mode. A script with no output, like output="false" or only #set, shows the generic placeholder "macro:velocity" with no hint of the script, which is the case of most templates of XWiki Standard but not of the documented example. Recorded OK on the most common example.
E2 errorsKOinvalid values are accepted silently, with no message. filter="nosuchfilter", filter="Indent" with a wrong case, filter="a b" and jars="nosuch.jar" render as if the parameter was not set. output="maybe" is read as false and the whole output disappears, and wiki="maybe" is accepted. The source is the free text field of filter and jars, and the boolean conversion of output and wiki. A jars value that is not a URL gives the message "Failed to add JAR URLs to the current class loader for [notaurl]", which is clear but is a technical stack.
E3 nestingOKin a list item, a table cell and a box the macro renders its output with no error, and a list, a table and a box in its content give a list, a table and a box, since the output is wiki syntax. The content is not editable in place in any of these cases.
E4 inline-supportOKthe macro declares inline support, and its output renders inside a sentence with no block element. A script that outputs block syntax gives the usual behavior of wiki syntax in an inline context.
E5 emptyN/AN/A for a generator. The editor shows the output of the script, or "macro:velocity" when it is empty, and the content can only be typed in the Edit Macro dialog.
E6 inplaceN/AN/A for a generator. The script is still edited only in a plain text area of 7 rows of the Edit Macro dialog, with no code editing aid, which is worth an improvement outside the criteria.

Parameters

ParameterC1 clarityC2 mandatoryC3 defaultsC4 input-assistanceC5 groupsC6 orderC7 alternativesC8 advancedC9 technicalC13 constraintsNotes
$contentOKOKN/AOKN/AOKN/AN/AN/AN/A

C1: the name "Content" and the description "the velocity script to execute" are clear for a developer macro.

C2: the content is mandatory, which is right, an empty script does nothing.

C4: a plain text area in the Edit Macro dialog, counted under E6.

C6: the content comes first, before the optional parameters.

filterKOOKOKKOOKOKN/AKOOKN/A

C1: the description "indicate which filtering mode to use" gives no possible value for a free field, and does not say what a filter does or that an empty value stands for the default configured in the wiki, indent unless changed. The valid values, none, indent and html, are in no description, and the documentation only mentions indent. The name is the ID.

C3: the empty field stands for the filtering mode configured for the wiki, indent by default, which is OK for a value that comes from the wiki setting, with C1 asking for the explanation. The documentation says the default is indent, and the macro declares none.

C4: a free text field for a fixed list of three filters, a select could offer them. A wrong value is accepted silently, see E2.

C8: a rarely used parameter, no example of the common use sets it and none of the XWiki Standard calls found sets it, but it is not marked as advanced.

jarsOKOKOKKOOKOKN/AKOKOKO

C1: the name is the ID, and the description with its examples is clear for a developer macro. It says "List of JARs" without saying how to separate several values.

C3: empty means no extra JAR, which is the right default.

C4: a free text field for attachment references or URLs, with no picker, and it is accepted silently when the attachment does not exist, see E2. The values are free text, so the KO is minor.

C8: a rarely used parameter, not set by any example nor by the XWiki Standard calls found, and not marked as advanced.

C9: inherited from the script macros and not documented for velocity: a user does not expect to add JARs to the class loader of a Velocity script, which is mostly a groovy need, so the field is only noise in the dialog.

C13: a list of references in a single field with the separator undeclared: "a.jar, b.jar" is refused with "Failed to add JAR URLs to the current class loader" and the description does not say which separator to use.

outputOKOKOKOKOKOKN/AOKOKOK

C1: the description "Specifies whether the output result should be inserted back in the page" is understandable for a developer macro. The English name is the ID, "output".

C3: the checkbox preselects the default, true.

C4: a checkbox for a boolean.

C6: no common example sets it, and it is visible in the group with only three other fields.

C8: output="false" is used by about one call out of ten in XWiki Standard, for scripts that only set variables, so it is not rarely used.

C9: realistic use, the examples of the documentation of the script macros set it.

wikiOKOKOKOKOKOKN/AKOOKOK

C1: the description "Specifies whether wiki syntax in the script execution result will be rendered or not" is clear for a developer macro. The English name is the ID, "wiki".

C3: the checkbox preselects the default, true.

C4: a checkbox for a boolean.

C8, minor: wiki="false" is a realistic but rare use, found once in the XWiki Standard calls, and the field is not marked as advanced.

C9: realistic use, for a script that outputs text with wiki characters.

KOs and tickets

Every KO needs a ticket covering it, see Report the KOs. One ticket can cover several KOs. Known issues filed for this macro are suggested in italics: link them as existing tickets when they cover the KO.

KOCriterionExisting ticketsNew tickets
L2L2 doc-parametersXINFRA-525
L3L3 doc-exampleXINFRA-526
E2E2 errorsXCOMMONS-3847 (partial), XRENDERING-823 (partial), XWIKI-25500 (partial), XWIKI-25579 (partial)
C1:filterC1 clarity, filterXWIKI-25475
C4:filterC4 input-assistance, filterXWIKI-23045 (partial)XWIKI-25500
C8:filterC8 advanced, filterXWIKI-25476
C4:jarsC4 input-assistance, jarsXWIKI-25568
C8:jarsC8 advanced, jarsXWIKI-25476
C9:jarsC9 technical, jarsXWIKI-25476
C13:jarsC13 constraints, jarsXWIKI-25476
C8:wikiC8 advanced, wikiXWIKI-25476
Success

Every KO is covered by a ticket.

Tickets

TicketOriginKOs coveredKOs partly covered
XCOMMONS-3847NewE2
XRENDERING-823NewE2
XWIKI-25475NewC1:filter
XWIKI-25476NewC8:filter C8:jars C8:wiki C9:jars C13:jars
XWIKI-23045ExistingC4:filter
XWIKI-25500NewC4:filterE2
XINFRA-525NewL2
XINFRA-526NewL3
XWIKI-25568NewC4:jars
XWIKI-25579NewE2

Known issues of this macro

No known issue is specific to this macro.
68 more known issues affect every macro: see the Known issues.

Get Connected