As of SiteMesh 2.0.2 Freemarker (.ftl) decorators are supported.
Here is an example of how such a decorator might look like:
Installation
Download Freemarker 2.3 (recommended) and copy it into WEB-INF/lib. The SiteMesh distribution comes with freemarker.jar v2.3rc3.
Add the following to WEB-INF/web.xml within the <web-app> tag:
Modify decorators.xml to reference a .dec file.
Context
FreemarkerDecoratorServlet puts some things into the context object that you should be aware of:
Basic context attributes
It makes all request, request parameters, session, and servlet context attributes available to templates through Request, RequestParameters, Session, and Application variables. For example :
The scope variables are also available via automatic scope discovery. That is, writing Application.attrName, Session.attrName, Request.attrName is not mandatory; it's enough to write attrName, and if no such variable was created in the template, it will search the variable in Request, and then in Session, and finally in Application.
It creates a variable with name JspTaglibs, that can be used to load JSP taglibs. For example:
Sitemesh context attributes
base |
request.getContextPath() |
title |
Parsed page title (<title>...<title>) |
head |
Parsed page head |
body |
Parsed page body |
page |
SiteMesh's internal Page object |