| Understanding Templates
Our basic templates are pretty simple to understand. They're almost exactly like regular html pages except for special placeholders which are inserted where we want the generated content to go. When the program 'publishes' a page it simply copies the template and replaces the 'placeholders' with the actual content.
Placeholders can look like this:
$job_name$
or this
<!-- template insert : $job_name$ -->
The second one works exactly the same as the first, the only difference is that when you view the template file directly it won't display because it's in a comment tag (sometimes this is desired). It will, however, be replaced with the appropriate data when the page is published.
Have a look at some of the templates in the templates/ directory.
Pretty simple so far? Now it gets a little more complicated. There are some instances when simply replacing placeholders with values isn't enough. When we need to create a list of items, for example, we need to take a few lines of html and repeat them for each item in the list.
We use special 'templatecell' tags to identify these blocks of HTML so the program can load them and insert them as many times as required. They typically look like this:
<!-- templatecell : row -->
list item $name$ goes here
<!-- /templatecell : row -->
For each record in the database, the HTML between the two tags is duplicated, the placeholders are replaced with their appropriate content for the given job and the HTML is displayed where a $list$ placeholder is.
|