VlibTemplate

vlibTemplate
Stable release
4.1.0
Type Template Engine
Website http://vlib.clausvb.de/

vlibTemplate is a template engine written in PHP. Programmers and web developers may use it for web development. vlibTemplate is a PHP class that is intended to make splitting PHP from HTML a simple and natural task, using markup tags. This class allows users to set values for variables, loops, if statements, etc. which are declared in the template.

vlibTemplate is a part of vLIB. It has an interface to vlibDate and vlibMimeMail.

Code example

Since vlibTemplate separates PHP from HTML, there are two files:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
   <title>{tmpl_var name='title_text'}</title>
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>

<body>

<p>{tmpl_var name='body_text'}</p>
<div>{tmpl_var name='div_cont'}</div>

</body>
</html>

Note that this file contains plain HTML and one markup tag. TMPL_VAR is used to display template variables, which are assigned in the PHP script:

require_once 'vlib/vlibTemplate.php';

$tmpl = new vlibTemplate('tmpl/basic.htm');

$tmpl->setvar('title_text', 'TITLE: This is the vLIB basic example ...');
$tmpl->setvar('body_text', 'BODY: This is the message set using setvar()');
$tmpl->setvar('div_cont' , 'DIV : This is div paragraph');
$tmpl->pparse();

Using the vlibTemplateCache can speed up the parsing process.

Features

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.