h4d / template
基本的PHP模板系统
v1.0.4
2018-05-20 14:06 UTC
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2024-09-14 20:04:08 UTC
README
这是一个非常基础的PHP库,帮助您处理纯文本格式模板(txt, html等)。
通过composer安装
使用以下命令安装最新版本:
$ composer require h4d/template
基本使用示例
使用构造函数
<?php
// Create a template
$template = new \H4D\Template\Template();
// Add vars to the template object
$template->addVar('name', 'WORLD');
// Render using the given file as template
echo $template->render('./template.txt');
使用静态方法(快速方法)
<?php
// Create a template & set the template file
$template = \H4D\Template\Template::create('./template.txt');
// Add vars to the template object
$template->addVar('name', '(static) WORLD');
// Render template (automagically cast to string)
echo $template;