Ruby Scriptlet Example
|
<%ruby
#
# Defer this page
#
if $conversation.query['defer'] == 'true'
if $conversation.defer
$conversation.stop
end
end
#
# Cache this page
#
$caching.duration = 5000
#
# Calling Java
#
include Java
import java.lang.System
print ' This page was dynamically generated at ', System::current_time_millis, ' ' # # An example of a method # def print_adapter adapter %>
Adapter: <%= adapter.attributes['name'] %> version <%= adapter.attributes['version'] %> Language used:<% print_adapter $executable.context.adapter %>Available languages:<% adapters = $executable.manager.adapters.to_array for adapter in adapters print_adapter adapter end %> |
The "id" attribute in the URL query is:<%= $conversation.query['id'] || '' %> A few tests:
<%
#
# Including a document
#
# This is identical to:
#
# $document.include '/triple/ruby/'
#
%>
<%& '/triple/ruby/' %>
<%
for i in 0 .. 9
%>
A multiple of three:
<%
print_triple i
%>
|