Extensions Wiki » Extensions » Ruby Macro

Ruby Macro

Last modified by Thomas Mortagne on 2013/06/04 08:25
cogAdds ability to write scripts in Ruby in wiki pages
TypeJAR
Developed by

XWiki Development Team

LicenseGNU Lesser General Public License 2.1
Installable with the Extension Manager

View Source

Download v5.0.3

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

Put the jar file into WEB-INF/lib folder and restart XWiki.


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.

Dependencies

  • org.xwiki.rendering:xwiki-rendering-api 5.0.3
  • org.jruby:jruby 1.6.3
  • org.xwiki.rendering:xwiki-rendering-transformation-macro 5.0.3
  • org.xwiki.platform:xwiki-platform-rendering-macro-script 5.0.3
Tags: ruby script
Created by Asiri Rathnayake on 2009/07/23 14:28

Download XWiki