lsolesen/php-template
Composer 安装命令:
composer require lsolesen/php-template
包简介
Lightweight template engine with the same interface as Savant3 and Smarty.
关键字:
README 文档
README
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 phpsavant.com.
Example
<?php
$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 -->
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>Banned</th>
</tr>
<? foreach($user_list as $user): ?>
<tr>
<td align="center"><?=$user['id'];?></td>
<td><?=$user['name'];?></td>
<td><a href="mailto:<?=$user['email'];?>"><?=$user['email'];?></a></td>
<td align="center"><?=($user['banned'] ? 'X' : ' ');?></td>
</tr>
<? endforeach; ?>
</table>
<!-- index.tpl.php -->
<html>
<head>
<title><?=$title;?></title>
</head>
<body>
<h2><?=$title;?></h2>
<?=$body;?>
</body>
</html>
统计信息
- 总下载量: 348
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-10-17