nojimage / cakephp-taltal
CakePHP TALTAL – PHPTAL 视图插件。此插件提供 PHPTAL 视图类
2.1.1
2013-08-02 12:42 UTC
Requires
- php: >=5.3.0
- composer/installers: *
- phptal/phptal: dev-master
This package is auto-updated.
Last update: 2024-08-29 03:57:59 UTC
README
PHP 5.3+, CakePHP 2.1+
此插件提供 PHPTAL 视图类
版权所有 2013,php-tips.com (http://php-tips.com)
插件安装
git submodule add -f https://github.com/nojimage/CakePHP-TALTAL.git plugins/Taltal
并获取 PHPTAL 库。
cd plugins/Taltal git submodule update --init
用法
在 app/Config/bootstrap.php 中
CakePlugin::load('Taltal');
或
CakePlugin::loadAll();
在 AppController 中
class AppController extends Controller {
// ...(snip)
public $viewClass = 'Taltal.Phptal';
// ...(snip)
}
在控制器动作中设置变量。
class PostsController extends AppController {
function index() {
$people = array(
array('name' => 'foo', 'phone' => '01-344-121-021'),
array('name' => 'bar', 'phone' => '05-999-165-541'),
array('name' => 'baz', 'phone' => '01-389-321-024'),
array('name' => 'quz', 'phone' => '05-321-378-654'),
);
$this->set(compact('people'));
}
}
并创建视图文件,扩展名为 .html 或 .xhtml 或 .zpt
例如:app/View/Posts/index.html
<table>
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr tal:repeat="person people">
<td tal:content="person/name">person's name</td>
<td tal:content="person/phone">person's phone</td>
</tr>
<tr tal:replace="">
<td>sample name</td>
<td>sample phone</td>
</tr>
<tr tal:replace="">
<td>sample name</td>
<td>sample phone</td>
</tr>
</tbody>
</table>
许可证
https://gnu.ac.cn/licenses/lgpl.html GNU Lesser General Public License
感谢
对 CakePHP2.0 的支持。感谢!: Juracy Filho https://github.com/juracy
PHPTAL :: 用于 PHP 5 的模板属性语言
使用 PHPTAL 进行模板:PhptalView 类 | The Bakery,一切关于 CakePHP