jmon/viewengine
最新稳定版本:1.0.0
Composer 安装命令:
composer require jmon/viewengine
包简介
Lightweight php template engine system
关键字:
README 文档
README
Features
-
Fast
-
Powerful
-
Easy
Installing
@todo
Getting started
- Simple template:
/base/path/|
|_ simple-template.phtml
|_ script.php
<!-- simple-template.phtml --> <!DOCTYPE html> <html> <head> <title><?= \jmon\TplEngine\View::get('title') ?></title> </head> <body> <h1><?= \jmon\TplEngine\View::get('title') ?></h1> </body> </html>
<?php // script.php use jmon\TplEngine\View; View::setBasePath('/base/path'); View::set('title', 'hello world!'); echo View::render('simple-template.phtml'); ?>
<!-- final rendering --> <!DOCTYPE html> <html> <head> <title>hello world!</title> </head> <body> <h1>hello world!</h1> </body> </html>
- Template with layout:
/base/path/|
|_ layout.phtml
|_ home/index.phtml
|_ script.php
<!-- layout.phtml --> <!DOCTYPE html> <html> <head> <title><?= \jmon\TplEngine\View::get('title') ?></title> </head> <body> <!-- Place where will be rendered the content of templates that extends this one --> <?= \jmon\TplEngine\View::content() ?> </body> </html>
<!-- home/index.phtml --> <?php \jmon\TplEngine\View::templateExtend('layout.phtml')?> <h1><?= \jmon\TplEngine\View::get('title') ?></h1>
<?php // script.php use jmon\TplEngine\View; View::setBasePath('/base/path'); View::set('title', 'hello world!'); echo View::render('/home/index.phtml'); ?>
<!-- final rendering --> <!DOCTYPE html> <html> <head> <title>hello world!</title> </head> <body> <h1>hello world!</h1> </body> </html>
- Use of partial:
/base/path/|
|_ template.phtml
|_ partial.phtml
|_ script.php
<!-- template.phtml --> <!DOCTYPE html> <html> <head> <title><?= \jmon\TplEngine\View::get('title') ?></title> </head> <body> <h1><?= \jmon\TplEngine\View::get('title') ?></h1> <?php \jmon\TplEngine\View::partial('partial.phtml')?> </body> </html>
<!-- partial.phtml --> <footer><?= \jmon\TplEngine\View::get('footer-text') ?></footer>
<?php // script.php use jmon\TplEngine\View; View::setBasePath('/base/path'); View::set('title', 'hello world!'); View::set('footer-text', 'Awesome footer!'); echo View::render('template.phtml'); ?>
<!-- final rendering --> <!DOCTYPE html> <html> <head> <title>hello world!</title> </head> <body> <h1>hello world!</h1> <footer>Awesome footer!</footer> </body> </html>
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-21