Groovy Macro

Version 22.2 by Vincent Massol on 2020/11/13 16:18

cogAdds ability to write scripts in Groovy in wiki pages
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Description

This is a shortcut for Script Macro equivalent to {{script language="groovy"}} to execute groovy scripts.

Usage

{{groovy}}
def list = ["one", "two"]
list.each { item ->
  println "* ${item}"
}
{{/groovy}}

Parameters definition

If Groovy script is not supposed to produce any output, for example, Groovy Class with just parameters is defined, declare  macro as:

{{groovy output="false"}}

See Script Macro for details.

Example

{{groovy}}
def list = ["one", "two"]
list.each { item ->
  println "* ${item}"
}
{{/groovy}}

Result

  • one
  • two

Note that since context is a reserved binding in JSR-223 specifications used for Scripting Macros, the XWiki Api Context is now accessible throught xcontext

Tags: groovy script
    

Get Connected