定制 gelembjuk/templating 二次开发

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

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

gelembjuk/templating

最新稳定版本:1.0.7

Composer 安装命令:

composer require gelembjuk/templating

包简介

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

README 文档

README

Common interface for different PHP templating engines like Smarty, Twig. This package allows to switch between engines witout changes in your PHP code.

The package was created to be able to migrate to different popular PHP templating engines without need to change my application code. However, it is still needed to modify templates.

Installation

Using composer: gelembjuk/templating require: {"gelembjuk/templating": "1.*"}

Additionally, you have to install a template engine you want to use - smarty/smarty or twig/twig (later i hope to add support of other engines).

Configuration

Configuration is done in run time with a constructor options (as hash argument)

$templateroptions = array(
		'templatepath' => $templatesdir, // directory where templates are stored
		'compiledir' => $compiledir,    // directory to use for compilation temp files. It is needed fro Smarty, but not Twig 
		'usecache' => false,       // don't cache . If true then use cache
		'cachedir' => $cachedir,   // path to cache directory. used if `usecache` is true
		'extension' => 'htm' // our templates files will have htm extension
	);

Usage

require '../vendor/autoload.php';

$templater = new Gelembjuk\Templating\SmartyTemplating();
// $templater = new Gelembjuk\Templating\TwigTemplating();

// init template engine
$templater->init($templateroptions);

$templater->setVar('firstname',"John");
$templater->setVar('lastname',"Smith");

$templater->setTemplate('homepage');

// fetch page page content
$pagecontent = $templater->fetchTemplate();

echo $pagecontent;

File homepage.htm in case of Smarty

<div>

<h1>Hello {$lastname}, {$firstname} </h1> 

</div>

File homepage.htm in case of Twig

<div>

<h1>Hello {{ lastname }}, {{ firstname }} </h1> 

</div>

Author

Roman Gelembjuk (@gelembjuk)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固