Ruby Macro
Last modified by Thomas Mortagne on 2026/04/29 12:17
![]() | Rendering macro to execute Ruby script |
| Type | JAR |
| Category | |
| Developed by | |
| Active Installs | 0 |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
Table of contents
Description
This is a shortcut for Script Macro equivalent to {{script language="ruby"}} for executing ruby scripts.
Usage
{{ruby}}
require 'java'
include_class 'java.util.TreeSet'
set = TreeSet.new
set.add "foo"
set.add "Bar"
set.add "baz"
set.each do |v|
puts "value: #{v}"
end
{{/ruby}}Parameters definition
See the Script Macro for details.
Example
{{ruby}}
if $xcontext.getUser() != "XWiki.XWikiGuest" then
puts "Hello [[#{$xcontext.getUser()}]]!"
else
puts "You are not logged in!"
end
{{/ruby}}Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Versions
Dependencies
Dependencies for this extension (org.xwiki.contrib:macro-ruby 10.1.0.0):
- org.xwiki.platform:xwiki-platform-rendering-macro-script 18.3.0
- org.jruby:jruby 10.1.0.0
- com.github.jnr:jnr-ffi 2.2.19
- com.github.jnr:jnr-posix 3.1.22
- com.github.jnr:jffi 1.3.15
