shakahl/hups-util-phptemplate 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shakahl/hups-util-phptemplate

Composer 安装命令:

composer require shakahl/hups-util-phptemplate

包简介

Extremely lightweight template class based on native PHP. Forked from: https://github.com/lsolesen/php-template/

README 文档

README

Introduction

This package is a part of the Hups Framework. It is an extremely lightweight template class based on native PHP.

This library is forked from: https://github.com/lsolesen/php-template/

 

Installation

https://packagist.org/packages/shakahl/hups-util-phptemplate

Add shakahl/hups-util-phptemplate as a requirement to composer.json:

{
    "require": {
        "shakahl/hups-util-phptemplate": "dev-master"
    }
}

Update your packages with composer update or install with composer install.

You can also add the package using composer require shakahl/hups-util-phptemplate and later specifying the version you want (for now, dev-master is your best bet).  

Usage example

 

Example for usage

<?php  
$path = './templates/';  

$tpl = new \Hups\Util\PHPTemplate('/path/to/template_file.php');
$tpl->some_title = 'User list';
$tpl->userArray = array(
    array(
        "id" =>  1,
        "name" => "John Doe1"
    ),
    array(
        "id" =>  2,
        "name" => "John Doe2"
    ),
    array(
        "id" =>  3,
        "name" => "John Doe3"
    )
);
$tpl->set('another_variable', 'some value');
$tpl->assign('another_variable2', 'some value');
$renderedOutput = $tpl->fetch('template-tpl.php');
$tpl->display('template-tpl.php');
?>

 

Example template file

<!-- test_template.tpl.php -->
<h1><?php echo $some_title; ?></h1>
<table>  
    <tr>  
        <th>Id</th>  
        <th>Name</th>  
        <th>Email</th>  
        <th>Banned</th>  
    </tr>  
    <?php foreach($userArray as $usr): ?>  
    <tr>  
        <td><?php echo $usr['id']; ?></td>  
        <td><?php echo $usr['name']; ?></td>  
    </tr>  
    <?php endforeach; ?>  
</table>
<p>
<?php echo $this->another_variable; // Can be used like this ?>
</p>

 

Unit testing

 

Under Windows

$ composer update
$ vendor/bin/phpunit​.bat

 

Under Linux

$ composer update
$ vendor/bin/phpunit​

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-11