Skip to content
Lightweight Template engine with the same interface as Savant3 and Smarty
Find file
Latest commit f6d4b85 Mar 24, 2016 @lsolesen Added TravisCI integration


PHP Template Engine

Very simple template engine for PHP Version 4. It is based on the article Beyond the template engine by Brian Lozier.

For a more current PHP 5 implementation of the same ideas, check out


$path = './templates/';

tpl = new Template($path);
$tpl->set('title', 'User List');
$body = new Template($path);
$body->set('user_list', fetch_user_list());
$tpl->set('body', $body->fetch('user_list.tpl.php'));
echo $tpl->fetch('index.tpl.php');

And it can be used with the following templates.

<!-- user_list.tpl.php -->
    <? foreach($user_list as $user): ?>
        <td align="center"><?=$user['id'];?></td>
        <td><a href="mailto:<?=$user['email'];?>"><?=$user['email'];?></a></td>
        <td align="center"><?=($user['banned'] ? 'X' : '&nbsp;');?></td>
    <? endforeach; ?>

<!-- index.tpl.php -->

Something went wrong with that request. Please try again.