SiteMesh - Velocity Decorators

As of SiteMesh 2.0.2 Velocity (.vm) decorators are supported.

Here is an example of how such a decorator (e.g. /decorators/main.vm) might look like:

#parse ("/includes/decorators/header.vm")
    <h2>$title</h2>
    $head
    <img src="$base/images/logo.gif" border="0">
    <td valign="top" class="body">
        <div class="header">
            <span class="pagetitle">$title</span>
        </div>
        $body
    </td>
#parse ("/includes/decorators/footer.vm")

Installation

<servlet>
    <servlet-name>sitemesh-velocity</servlet-name>
    <servlet-class>com.opensymphony.module.sitemesh.velocity.VelocityDecoratorServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>sitemesh-velocity</servlet-name>
    <url-pattern>*.vm</url-pattern>
</servlet-mapping>

A working example is included with the SiteMesh distribution, under the src/example-webapp directory.

Context

VelocityDecoratorServlet puts some things into the context object that you should be aware of:
$request (from VelocityViewServlet) The HttpServletRequest object
$response (from VelocityViewServlet) The HttpServletResponse object
$session (from VelocityViewServlet) The HttpSession object
$application (from VelocityViewServlet) The ServletContext object
$base request.getContextPath()
$title Parsed page title (<title>...<title>)
$head Parsed page head
$body Parsed page body
$page SiteMesh's internal Page object
Anything else Search for the attribute by that name in the request, session and application scopes