XiTemplate Home Page XiTemplate
[ class tree: XiTemplate ] [ index: XiTemplate ] [ all elements ]
Prev Next
Template Anatomy (continued)

Template Anatomy (continued)

Description of template blocks and variables

Templates are made up of blocks and variables. The following sections will attempt to describe both in detail.

Template Variables

Templates can also have variables. A template variable is something that will be replaced when a template is parsed. This behavior is known as interpolation.

Template variables must begin with a curly brace { followed by some text and end with a curly brace }.

Example:

<!-- BEGIN: main -->

<p>Here is a template variable: {NAME}.
This variable will be replaced when 
the template is parsed</p>

<!-- END: main -->

Template variables do not need to be CAPITALIZED however, this convention makes template variables stand out in both your template and in your code.

Template variables should not contain spaces or non standard characters. Alphanumeric characters with hyphens and underscores are fine.

Arrays

XiTemplate supports interpolation of multidimensional arrays. Array template variables differ slightly from standard template variables in that they contain a dot delimited list of array keys after the variable name.

Example

<!-- BEGIN: main -->

<p>A normal template variable: {LAST_NAME}</p>
<p>An array template variable: {NAME.first_name} {NAME.last_name}</p>

<!-- END: main -->

Multi dimensional array example

<!-- BEGIN: main -->

<p>Multidimensional array: {PERSON.name.first_name} {PERSON.name.last_name}</p>

<!-- END: main -->

There is one more type of template variable that can be interpreted by XiTemplate as a command. This variable is "FILE". FILE variables contain special instruction for XiTemplate to include and interpolated another file into the current position of the FILE call.

Example

<!-- BEGIN: main -->

<p>Here is an included file</p>

{FILE "examples/myfile.tpl"}

<!-- END: main -->

Files included by FILE command are treated as though they were in the current block before parsing so any template variables that would have been assigned in the current block will apply to the included file as well.

Included files can also contain additional blocks and sub blocks.

Included files can also contain FILE calls to additional files to be included!

Warning: Do not let a file call itself with the FILE command. This will included the file, which will include itself, which will include itself, which will include itself....we can do this all day.

Prev Up Next
Template Anatomy XiTemplate Manual XiTemplate Logic

Documentation generated on Fri, 20 Aug 2004 10:57:40 -0500 by phpDocumentor 1.3.0RC3