VOOT (Vanilla Object Oriented Templates)

Submitted by andy on Sat, 10/27/2007 - 20:04.

VOOT is a simple (‘vanilla’) PHP class written in 2003 for creating web pages with templates. It supports user-defined HTTP headers, and it is capable of processing PHP contained in rendered templates. This class was written with simplicity and flexibility in mind; templates can take the form of any text-based file, and you can define as many content placeholders as you like in each template. To indicate a placeholder in a template, you just surround a key word with percentage signs. VOOT was originally used to generate its own information and download page at my previous portfolio web site

Example

The first step to using VOOT is to come up with a template. A simple HTML template might look like this:

%HEADTITLE% %PAGETITLE%

%CONTENT%

Three placeholders were defined in the template by surrounding key words with the percent sign: HEADTITLE, PAGETITLE, and CONTENT. We’ll need to keep that in mind when we write the script we want to use our template in: setElement("HEADTITLE", "Templates are Handy"); $myVoot->setElement("PAGETITLE", "Create pages with VOOT!"); $myVoot->setElement("CONTENT", "

Why maintain multiple static pages when you can use a single template instead?

"); /* Step 4: Render the page: */ $myVoot->render(); ?> The HTML source of the rendered template looks like this:

Templates are Handy Create pages with VOOT!

Why maintain multiple static pages when you can use a single template instead?

Image(s):