Velocity Template Example
|
<%velocity
##
## Defer this page
##
#if($conversation.query.defer == 'true')
#if($conversation.defer())
$conversation.stop()
#end
#end
##
## Cache this page
##
#set($caching.duration = 5000)
##
## Calling Java
##
## Velocity is a templating language, not a full-blown scripting language. As such, it's missing some
## features we need! In this case, we want to call a static method. So, we'll just use a programming
## language scriptlet to fill in the gaps.
## Let's make sure Velocity interprets this before switching to the helper
#set($thisAdapter = $executable.context.adapter)
%><%& '/triple/velocity-helper/' %><%
This page was dynamically generated at $conversation.locals.currentTimeMillis ## ## An example of a macro ## #macro(printAdapter $adapter)
Adapter: $adapter.attributes.name version $adapter.attributes.version Language used:#printAdapter($thisAdapter)Available languages:#foreach($adapter in $executable.languageManager.adapters) #printAdapter($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/velocity/')
##
%><%& "/triple/velocity/" %><%
#foreach($i in [0..9])
A multiple of three:
#printTriple($i)
|