Ruby Macro

This is a XWiki macro, which isn't bundled with any XWiki product by default.
Macro developed by the XWiki Development Team.
This macro can be downloaded.

Ruby Macro

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

Installation

To use ruby macro, you need to install following three libraries inside WEB-INF/lib directory of your XE installation:

Once these libraries are in place, you need to restart your XE installation for the changes to take effect.

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 #{$xwiki.getUser().getEmail()}!"
else
  puts "You are not logged in!"
end
{{/ruby}}

Result

You are not logged in!

Tags:
Created by Asiri Rathnayake on 2009/07/23 14:28
Last modified by Asiri Rathnayake on 2009/10/14 12:16

This wiki is licensed under a Creative Commons license
2.2.1.27354