vlibTemplate

vLib Logo

1. Synopsis

vlibTemplate is a template engine written in PHP. Programmers and web developers may use it for Web development. vlibTemplate is a PHP class (computer science) that is intended to make splitting PHP from HTML a simple and natural task. Benefits of using vlibTemplate:

The following images and explanations were created by Skrol for TinyButStrong another template engine.


Without a template engine, your PHP program looks like this:
HTML and PHP are embedded with each other in the same page.
- It takes a long time to code.
- It's hard to read.
- It's not simple to perform maintenance.
- It's complicated to manage several pages in one program.
- It needs a programmer, who is good at coding HTML.

With a template engine, your program looks like this:

There is one program with pure PHP and one template with pure HTML.

The template engine (vlibTemplate) enables you to merge the HTML page with data from your program. If you don't know HTML, your template can be designed without problem using a visual editor such as Dreamweaver or Frontpage.


But there are more benefits:
The Template Engine also enables you to easily manage:
- The choice of a page among a set of possible pages.
- The inclusion of a page inside another like frames.
- The presentation of data coming from databases such as MySQL, PostgreSQL, Oracle, Informix, ODBC or SQL Server.
- Display or hide an area based on the value of a PHP variable.

And a template engine is very much appreciated by professionals because the PHP development can be given to one person and HTML development to another. Page design can be changed without programming changes, making re-designs a lot easier.


The most important benefit is structure and clean code. Mosts scripts contain lines like

echo "<table width='80%'>\n\t<tr bgcolor='$color'>";

or a mixture of PHP and HTML code. You can avoid such code using a template engine like vlibTemplate or TinyButStrong.