Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -293,7 +293,7 @@ 293 293 294 294 Most JSR223 based scripting languages reinject the created variable in the current ##ScriptContext## which means you can define a variable in a Groovy script and reuse it in a following Python script for example. 295 295 296 -Since 4.1M2 a bridgehas beenwritten forVelocity(whichisot based on JSR223)to allowit toaccess the current ScriptContext variable soyoucando things like:296 +Since the Velocity implementation isn't based on JSR223, we have also set up a bridge so that Velocity scripts can access the current ##ScriptContext## variables. This allows for example to define a variable in a Groovy script and then reuse it in a Velocity one: 297 297 298 298 {{code}} 299 299 {{groovy}} ... ... @@ -305,6 +305,18 @@ 305 305 {{/velocity}} 306 306 {{/code}} 307 307 308 +Starting with XWiki 8.3 the Velocity bridge has been improved and it's now possible to do the opposite, i.e. define a variable in Velocity and access it from another scripting language. For example: 309 + 310 +{{velocity}} 311 +## Setting some script binding in Velocity 312 +#set($myvar = "toto") 313 +{{/velocity}} 314 + 315 +{{groovy}} 316 +// Lets use the script binding that has been set in previous script 317 +print myvar 318 +{{/groovy}} 319 + 308 308 Note that you can also share variables by setting them in the XWiki Context (##xcontext## binding). 309 309 310 310 = Scripting In XWiki Syntax 1.0 =