定制 anovsiradj/cutter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

anovsiradj/cutter

最新稳定版本:4.0.0

Composer 安装命令:

composer require anovsiradj/cutter

包简介

Flexible Template Library

README 文档

README

Flexible Template Library. Inspired by Blade (Laravel) and Twig (Symfony).

Tested on PHP 5.6, ~7 and ~8.

Installation

Download this source or via Composer:

composer require anovsiradj/cutter

Example

/index.php

require 'Cutter.php'; // directly or composer

$cutter = new anovsiradj\Cutter;
$cutter->set('layout','/layouts/main');

$cutter->data('page_title', 'My Posts'); // set variable

$cutter->view(
	'/pages/home',
	['date_today' => date('Y-m-d')], // set variable(s)
);

/layouts/main.php

use section() to define section

<!DOCTYPE html>
<html>
	<head>
		<title><?= $page_title ?></title>
	</head>

	<body>
		<div>
			<?php $cutter->section('content') ?>
		<div>

		<?php $cutter->section('script') ?>
	</body>
</html>

/pages/home.php

use begin() and end() to output-buffer section

<?php $this->begin('content') ?>
<ul>
	<li>Post title 1</li>
	<li>Post title 2</li>
	<li>Post title 3</li>
</ul>
<?php $this->end() ?>

<?php $this->begin('script') ?>
<script>alert('date today is <?php echo $date_today ?>')</script>
<?php $this->end() ?>

for more, see /example/.

Reference

Class Methods

get( $key ) : void;
set( $key, mixed $val ) : void;

data( mixed $any [, mixed $val] ): mixed;

load( $file [, bool $isob = false] ): void;

view( mixed $name [, array $data = [] [, bool $render = true ] ] ) : void;

render( [array $data = [] ] ) : void;

section( $name ) : bool;

begin( $name ) : void;
end(): void

Development

TODO:

  • single file library / phar?
  • inheritance
  • dynamic path
  • dynamic view

All suggestions are welcome. Thanks.

Reference

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-02