![]() |
||
|
||
![]() |
As represented visually in the picture, the data model is organized hierarchically, as a tree. The blue balls represent the variables that are available to the template. Except for the topmost object, the root, each object has exactly one parent (that's the ball that you reach first when you go upward along the black line.) Variables have zero or more subvariables. You can access any variable (blue ball) by starting at the root and going down along the edges (black lines).
The following examples are based on the data model represented below:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
In the Quick Start we introduced three basic types of objects that you can use from a template: scalars, hashes and sequences. That was a simplification. In fact a variable may have more than one of these abilities:
Storing a single value. In the example: the user, name and price objects do this. Objects like that are called scalars .
Acting as a holder or container for other objects and associating a unique lookup name with each one. In the example: the root and the items in the animals list do this. They are called hashes
Acting as a holder or container for objects in a sequence. The animals object above is an example of this. Object like this are called sequences.
Calculating something based on parameters you give, and then returning the result as a new object. We have not yet seen an example of this. Objects like this are called methods.
Acting as a user-defined directive (user-defined FTL tag). Such variables are called macros and transforms.
The abilities of an object determine the ways you can use it in your template. Typically the programmer will create a data model for you where each variable has only one of these abilities, but technically it is possible that a variable has more than one (even all) of the above abilities. For example in the data model below, mouse is both a scalar and a hash:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
If you merge this template with the above data model:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
the output will be:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
![]() |
||
|
||
![]() |
![]() |
|
Page generated: 2006-03-15 13:49:01 GMT | FreeMarker Manual -- For FreeMarker 2.3.6 |