script

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

Audit

Macro ID
script
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
velocity groovy

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/Script%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-script/src/main/java/org/xwiki/rendering/macro/script/AbstractJSR223ScriptMacro.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, D3velocity, groovy
Other sources specific to this macro
CriterionResultNotes
D1 wordingOK"Script" is the generic name of a macro that runs code in any JSR223 language, so it says what the macro does. The macro is audited as a developer macro, in the Development category. The French name is "Script" too, and the German one is "Skript".
D2 summaryOK"Execute script in provided script language." 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 velocity.
D4 quick-actionOKQuick Actions finds the macro first for "script" and for the German "Skript", ahead of Groovy, PHP, Python, Ruby and Velocity. "execute script", "run code", "python script" and "run script" do not find it, and "groovy" finds only the Groovy macro. A technical macro named after its technology is OK even when few synonyms find it, like html. The French name is the same as the English one and the German one differs, so the name is checked in two languages.
L1 consistencyOKcompared with velocity and groovy, 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/Script%20Macro, not in the new documentation. The content is not documented as a parameter, the documentation states no default for language, and it documents the script bindings xwiki, xcontext, request, response, doc and services, which are not parameters.
L3 doc-exampleOKExample 2, a python script that renders "3", and Example 3, a groovy script that prints a list, show the common use and render without error. Example 1 is a syntax template with placeholder values, like in the velocity documentation, and does not count. Example 2 is used as the most common example, since no public XWiki Standard page call was found by the GitHub code search.
I1 patternOKcompared with the reference generator, children. The Script 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 {{script/}} written in the source, or with an empty content, 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 focusKOthe language is essential but not mandatory. Without it, {{script}}1+2{{/script}} does not run the script and renders the source text "1+2" as plain text, with no error. The Edit Macro dialog does not require it either, so a user can insert a macro that does nothing, like the jira server fields.
E1 wysiwygOKwith a script that prints text, the editor shows its rendered output, "3" for Example 2, the same as in view mode, also after reopening the page. A script with no output, like output="false" or only an assignment, shows the generic placeholder "macro:script" with no hint of the script. Recorded OK on the most common example, like velocity.
E2 errorsKOinvalid values are accepted silently. language with no value renders the source text as plain text, output="maybe" is read as false and the whole output disappears, wiki="maybe" is accepted, and an unknown parameter is ignored, the last one being generic. A wrong language, like "nosuchlanguage", "PYTHON" with a wrong case or "python ruby", gives the clear message "Can't find script engine with name [...]" that names the engine and not the parameter. A jars value with a missing attachment gives the same message about the python engine instead of the missing attachment, and "a.jar, b.jar" with a space gives it too, so the cause is wrong. A jars value that is not a URL gives "Failed to add JAR URLs to the current class loader for [notaurl]".
E3 nestingOKin a list item, a table cell and a box the macro renders its output with no error. The content is code, so a list, a table or a box typed as the script gives the syntax error of the script language, which is expected, and the technical message counts under E2. 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.
E5 emptyN/AN/A for a generator. The editor shows the output of the script, or "macro:script" 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 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.

jarsOKOKOKKOOKOKN/AKOOKKO

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

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

C4, minor: a free text field for attachment references or URLs, with no picker, and a missing attachment is reported as a missing script engine, see E2. The values are free text, so the KO is minor.

C6: the field comes first, before the language that the common example sets, but both are visible in the dialog without scrolling, so it is OK.

C8: a rarely used parameter, set by no example of the documentation, and it is not marked as advanced.

C9: the parameter belongs to the script macros and a script in python, groovy or another engine can need a library on its class loader, so it has a realistic use, even with no documented example.

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

languageKOKOOKKOOKOKN/AOKOKN/A

C1, minor: the description "The identifier of the script language ("groovy", "python", etc)" gives examples of values, which is OK for a free field, but it does not say that an empty value runs nothing and shows the script as text, and that the identifier is case sensitive, "PYTHON" is refused.

C2: the macro cannot do anything without it: with no language the script is not run and its source is rendered as plain text, see I5. It should be mandatory, so this is a KO.

C3: the field opens empty and no single language is used in most cases, so no value is worth preselecting. Since it should be mandatory, an empty first field is OK.

C4: a free text field for an identifier chosen among the script engines installed on the wiki, a select could offer them, and a wrong value is refused with a message about the engine, see E2.

C5: four fields in the group, content included five, within the limit.

C6: the field is second, after jars, and visible in the dialog without scrolling, so it is OK.

C8: it is the essential parameter of the macro, so it is rightly not advanced.

C9: realistic use, every example of the documentation sets it.

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 the way to run a script that only sets variables, which is a frequent use, so it is not rarely used. Recorded like output of velocity.

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, for a script that outputs text with wiki characters, and the field is not marked as advanced. Recorded like wiki of velocity.

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
I5I5 focusXWIKI-25476
E2E2 errorsXCOMMONS-3847 (partial), XRENDERING-823 (partial), XWIKI-25500 (partial), XWIKI-25579 (partial)
C4:jarsC4 input-assistance, jarsXWIKI-25568
C8:jarsC8 advanced, jarsXWIKI-25476
C13:jarsC13 constraints, jarsXWIKI-25509
C1:languageC1 clarity, languageXWIKI-25475
C2:languageC2 mandatory, languageXWIKI-25476
C4:languageC4 input-assistance, languageXWIKI-23045 (partial)XWIKI-25500
C8:wikiC8 advanced, wikiXWIKI-25476
Success

Every KO is covered by a ticket.

Tickets

TicketOriginKOs coveredKOs partly covered
XCOMMONS-3847NewE2
XRENDERING-823NewE2
XWIKI-25475NewC1:language
XWIKI-25476NewC2:language C8:jars C8:wiki I5
XWIKI-23045ExistingC4:language
XWIKI-25500NewC4:languageE2
XINFRA-525NewL2
XWIKI-25509NewC13:jars
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