Simple Models

Simple implemations of hashes, lists, strings, and numbers have been provided as a convenience: SimpleHash, SimpleSequence and SimpleScalar and SimpleNumber respectively. Unless you're doing something highly unusual, you'll want to use a SimpleHash for the root node.

In many cases, it will be sufficient to copy your data from its original source into a tree of SimpleScalar, SimpleSequence and SimpleHash objects. If you want to implement lazy evaluation, or if you want to wrap existing data objects for use with templates, you'll want to make adapter or wrapper classes that implement the TemplateModel interfaces. Alternatively, check the section "Models for Arbitrary Java Objects". See the sample code for an example.