承接 jmon/viewengine 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-21