imScript Manual


Velocity

« Back  |  Next »
Introduction
General information
Text field
Image field
Page information
Links & Menu
Include
Data tags
User data
Date tags
Velocity
API samples
JSP
imScript tags list
RSS feed
Velocity is a Java-based template engine. It permits web page designers to reference methods defined in Java code. Web designers can work in parallel with Java programmers to develop web sites according to the Model-View-Controller (MVC) model, meaning that web page designers can focus solely on creating a well-designed site, and programmers can focus solely on writing top-notch code. Velocity separates Java code from the web pages, making the web site more maintainable over the long run and providing a viable alternative to Java Server Pages (JSPs) or PHP.

Velocity can be used to generate web pages, SQL, PostScript and other output from templates. It can be used either as a standalone utility for generating source code and reports, or as an integrated component of other systems. When complete, Velocity will provide template services for the Turbine web application framework. Velocity+Turbine will provide a template service that will allow web applications to be developed according to a true MVC model.

The Velocity User Guide is intended to help page designers and content providers get acquainted with Velocity and the syntax of its simple yet powerful scripting language, the Velocity Template Language (VTL). Many of the examples in this guide deal with using Velocity to embed dynamic content in web sites, but all VTL examples are equally applicable to other pages and templates.

The main imScript tags for Velocity are: <?imcms:velocity?> and <?/imcms:velocity?>.
Once a value has been assigned to a variable, you can reference the variable anywhere in your HTML document but between imScript Velocity tags. In the following example, a value is assigned to $foo and later referenced:

<?imcms:velocity?>
#set( $foo = "Velocity" ) Hello $foo World!
<?/imcms:velocity?>

The result is a web page that prints "Hello Velocity World!".

imScript has 4 predefined objects it links to:
Example:

<ul>
#foreach($key in $document.getMenus())
        <ul>
           #foreach($menu_key in $key.getVisibleMenuItems())
                 <li><a href='$menu_key.getDocument().getUrl()'>$menu_key.getDocument().getUrl()</a></li>
            #end
       </ul>
    </li>
#end
</ul>

Read more about Velocity on http://jakarta.apache.org/velocity/docs/user-guide.html

[Help for the whole system | imScript manual | All documentation]

Suggestions or comments? Please send us a mail: info@imcode.com