Smart Sites Templating

Introduction

SmartSites extends Velocity Engine in two ways:

  • with JAVA references
  • adding a post-processor to enable more powerful features.

JAVA references can be used both in standard processing and post-processing operations.

Before reading this section, be sure to know Velocity Template Language (see also “References” and “Directives“)

The Post-Processor

Once template processing is terminated and all output has been produced, SmartSites start a post-processing procedure that analyze all produced pages for a second processing cicle.

Post-Processing allow you to create scripts that can make use of generated “pages” collection.
PAGES collection contains all produced pages and their data (for example the item that produced that particular page).

In real world application the post-processing is used to produce menus or other navigation system based upon produced pages. In fact, is very easy to produce a menu that links at all produced pages simply looping on “pages” collection items and adding a “<a>” markup linking to output relative path.

The Post-Processor Syntax

Post-Processor instructions cannot be written using same syntax as other commands. Velocity special characters ($, #) must be replaced with new tags.

The REFERENCE character $ is replaced with [r] tag, and DIRECTIVE character # is replaced with [d] tag.
So, writing :

[d]set ([r]foo="this is post processed")

will be replaced with

#set ($foo="this is post processed")

during post processing.