Web Oriented Object Framework

User Guide (Version 0.5b4)

User Guide (Version 0.5b4)

Template based page sections

Like most other frameworks, Woof! separates program logic from the presentation by using templates to implement the latter. A template in Woof! is a combination of HTML text markup with Tcl code as the simple example below shows.

<p>The current time is [clock format [clock seconds] -format %T].</p>

In the above example, the template processor will replace the Tcl code in brackets with its result, thereby generating a HTML fragment displaying the current time in a paragraph.

Locating page templates

When the fetch method of the page object is called to retrieve a page section that has not already been stored in the object, it searches the file system for a suitable template from which the requested page section can be generated.

The algorithm of locating a layout for a page is the same as that used for page sections and is detailed in Locating templates. The method described there allows flexible sharing of page sections within, and between, controllers and controller trees while simultaneously allowing specialization for specific controllers or even actions within a controller.

Nesting page sections

Page section templates may themselves contain page section templates, just like layouts. For example, this user guide actually uses the default Woof! layout which references main page section. Instead of having a separate main section for each chapter (action), the user guide has only one template ug-main.wtf. This sets up the previous and next chapter links and then includes the statement

% if {![page fetch content content]} {
    set content "<p>This section is still to be written.</p>"
% }

Woof! will then locate a page section named content and insert it.

Page template processing

The syntax used in the template depends on the template processor. Currently, Woof! only supports the syntax defined in Woof! Template Format.

The processing of the template is done in the context of the controller object. The Tcl code in the template can therefore invoke any method of the controller or access any object instance variable using the standard Tcl syntax.