Groovy saying hello

     $groovy.set("name", "world")
     $groovy.eval('"Hello $name!"')
$groovy.set("name", "world") $groovy.eval('"Hello $name!"')

Calling a dotCMS Java Class from Groovy

     $groovy.eval('com.dotmarketing.util.UtilMethods.capitalize("hello")')
$groovy.eval('com.dotmarketing.util.UtilMethods.capitalize("hello")')

Creating a Groovy Object and calling a method on it

$groovy.evalExpression('/demos/scripting/groovy/groovy-greeter.gy','hm.hello("dotCMS")')
The Contents of the groovy-greeter.gy are

class Greeter {
	def hello(name) {
		"hello ${name}!"
	}
}
def hm = new Greeter()

$groovy.evalExpression('/demos/scripting/groovy/groovy-greeter.gy','hm.hello("dotCMS")')
© 2017 dotCMS Inc. All rights reserved.