ark/template
最新稳定版本:v0.1.2
Composer 安装命令:
composer require ark/template
包简介
Native PHP template engine
README 文档
README
Native PHP template engine
Installation
composer require ark/template
Usage
use Ark\Template\Engine; $template = new Engine('/path/to/templates/root'); $template->render('index.php', [ 'username' => 'hello' ]);
layout.php:
<!DOCTYPE html> <html> <head> <title><?php $this->block('title');?></title> </head> <body> <?php $this->block('header');?> <?php $this->begin('content');?><?php $this->end();?> <?php $this->block('footer');?> </body> </html>
index.php:
<?php $this->extend('layout.php');?> <?php $this->begin('title');?>Page Title<?php $this->end();?> <?php $this->begin('content');?> Page Content <?php $this->end();?> <?php $this->begin('footer');?> Custom footer <?php $this->end();?>
Markups
Declare layout:
<?php $this->extend('layout.php');?>
Declare a block:
<!-- empty block --> <?php $this->block('blockname');?> <!-- block with content --> <?php $this->begin('blockname');?> Block content <?php $this->end();?>
Include another template:
<?php $this->render('another.php');?>
Template Functions
Escaping:
<?=$this->escape($username)?> <!-- or for short --> <?=$this->e($username)?>
Filter:
<?=$this->filter($username, 'strtolower|trim')?> <?=$this->e($username, 'strtolower|trim');?>
统计信息
- 总下载量: 296
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-22